prototype my function, please

Stephen Clamage steve at taumet.com
Wed Jun 6 02:20:22 AEST 1990


In article <16790 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>On the implementation that I normally use, exit() is known to be a dead
>function.  Hence, adding a `return' statement would *create* a warning about
>unreachable code.

It seems some compilers complain about return, and some about absence of
return.  What to do?  What to do?

>Besides which, you can't just write `exit(0); return 0;'.  You also have to
>include a comment that says why you're doing something so silly, lest the next
>person to read the code think you did it out of ignorance.

True enough.  You can add a return following the exit, risking warnings
from the compiler, or omit it, risking warnings from the compiler.  In
this particular case, it would seem more sensible to omit the return,
since the ANSI standard says that exit cannot return to its caller.
With non-ANSI compilers, I have no preference.

My major point, however, was the hypothetical program by the orginal poster
which is intended to exit from some nested function and never get back to
main().  If we for the moment assume this is good programming practice,
I claim you still want a "return x;" at the end of main(), with a comment
saying this is an error return.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list