Connecting Tech Pros Worldwide Help | Site Map

Functions problem

  #1  
Old December 30th, 2005, 09:55 AM
itportal
Guest
 
Posts: n/a
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

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

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

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

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

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

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

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

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
easy pointers to functions problem Michael answers 11 August 7th, 2006 06:45 AM
XML Functions problem Bryan Dickerson answers 20 November 23rd, 2005 04:46 AM
Callback functions problem ajay.sonawane@gmail.com answers 11 July 23rd, 2005 06:05 AM
Overriding virtual functions problem AGoTH answers 9 July 19th, 2005 05:15 PM
simple require_once / config / functions problem will taubin answers 2 July 17th, 2005 01:55 AM