recursion - Recursive C void function and return keyword -


does know internal differences between :

void recfoo1(int bar){   if (bar == 0)     return ;   recfoo1(bar - 1); } 

and

void recfoo2(int bar){   if (bar == 0)     return ;   return recfoo2(bar - 1); } 

i convinced better put return keyword. if recursive function not void function, 1 warning -wreturn-type. these 2 piece of code compiled/executed same way or not ? internal differences machine ?

my example of function stupid constitute kind of minimal example...

the c standard quite clear on this, recfoo2 example not valid c program:

6.3.2.2 void

the (nonexistent) value of void expression (an expression has type void) shall not used in way, ...

and

6.8.6.4 return statement

constraints

a return statement expression shall not appear in function return type void.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -