Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 30th, 2005, 09:55 AM
itportal
Guest
 
Posts: n/a
Default Functions problem

Hello,

I've got the following problem. FuncB uses recursion and calls itself.
Sometimes FuncB calls FuncA, but then FuncA should call FuncB ... which
actually returns an error..

void FuncA(){
FuncB();
}

void FuncB(){
FuncB();
FuncA();
}

Ani ideas how to make that thing work ...

  #2  
Old December 30th, 2005, 10:05 AM
marcwentink@hotmail.com
Guest
 
Posts: n/a
Default Re: Functions problem

> ... which actually returns an error..

What error? If your call stacks goes out of limit, probably you should
write something like

void FuncA(){
if ( "not enough yet")
FuncB();
}


void FuncB(){
FuncB();
if ( "not enough yet")
FuncA();
}

somehow the recursion must stop at some time

  #3  
Old December 30th, 2005, 10:15 AM
itportal
Guest
 
Posts: n/a
Default Re: Functions problem

The recursion has an end, but I get:
"conflicting types for 'FuncB' "

  #4  
Old December 30th, 2005, 10:15 AM
itportal
Guest
 
Posts: n/a
Default Re: Functions problem

plus:
"previous implicit declaration of 'FuncB' was here"

  #5  
Old December 30th, 2005, 10:15 AM
marcwentink@hotmail.com
Guest
 
Posts: n/a
Default Re: Functions problem

itprotal:
[color=blue]
> The recursion has an end, but I get:
> "conflicting types for 'FuncB' "[/color]

It's still a bit unclear what the exact error is, is the compiler
complaining about the return type of function FuncB? Could you post the
whole and complete message, and even some code, may-be?

  #6  
Old December 30th, 2005, 10:15 AM
Luke Meyers
Guest
 
Posts: n/a
Default Re: Functions problem

Did you declare FuncB before using it in FuncA? It sounds as though
perhaps you didn't.

If that's not it, then I suggest that you should post the actual code
which causes this problem, because nothing in the snippet you posted is
missing whatever it is that's causing your code not to work.

Luke

  #7  
Old December 30th, 2005, 10:25 AM
marcwentink@hotmail.com
Guest
 
Posts: n/a
Default Re: Functions problem

> "previous implicit declaration of 'FuncB' was here"

Could you possibly have mistaken a statement that calls FuncB, and a
statement that defines FuncB

Like:

// defines the function, make the following code aware there is such a
function, but does not call it
void FuncB(int j, int k);


// calls the function
FuncB(j,k);

the difference is the types you declare in a definition, "void" as
return, and two "ints" for the parameters in this example.

Marc

  #8  
Old December 30th, 2005, 10:35 AM
itportal
Guest
 
Posts: n/a
Default Re: Functions problem

The code is very long an complicated.

I have probably made wrong declarations. I declared the functions and
now I get the error:
[Linker error] undefined reference to `FuncA'

  #9  
Old December 30th, 2005, 10:35 AM
itportal
Guest
 
Posts: n/a
Default Re: Functions problem

Oppps ... I've mistaken the name of the funcs.

Now everything is OK.

The problem had been that I haven't decalred the funcs. So long code
that I get lost in it ;)

10x

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles