
December 30th, 2005, 09:55 AM
| | | 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 ... | 
December 30th, 2005, 10:05 AM
| | | 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 | 
December 30th, 2005, 10:15 AM
| | | Re: Functions problem
The recursion has an end, but I get:
"conflicting types for 'FuncB' " | 
December 30th, 2005, 10:15 AM
| | | Re: Functions problem
plus:
"previous implicit declaration of 'FuncB' was here" | 
December 30th, 2005, 10:15 AM
| | | 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? | 
December 30th, 2005, 10:15 AM
| | | 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 | 
December 30th, 2005, 10:25 AM
| | | 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 | 
December 30th, 2005, 10:35 AM
| | | 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' | 
December 30th, 2005, 10:35 AM
| | | 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 |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | 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.
|