prototype my function, please

Stephen Clamage steve at taumet.COM
Tue Jun 5 02:03:47 AEST 1990


In article <1990Jun2.091606.9125 at druid.uucp> darcy at druid.UUCP (D'Arcy J.M. Cain) writes:
> ...
>#include <stdio.h>
>int main(int argc, char **argv)
>{
>	printf("%s has %d arguments\n", *argv, argc);
>	exit(0);
>}
>
>The compiler will give a warning that a function (main) which should
>return an int does not return anything. ...
>You now have added code (which won't be optimised out) which has no other
>purpose than to shut the compiler up. ...

Are you really concerned about one return statement in one function in
the entire program taking up code space but never being executed?

Do you ever include error-checking code in your programs to catch
"impossible" conditions?  You expect such code never to be executed,
and it surely uses more code space than "return 0;" at the end of main().

>In practice the exit may not even be in the main routine.

But what happens if *that* exit doesn't get executed (presumably due
to an error), and the program *does* return to main?  You should in
that case return some error value rather than 0 anyway, so you find out
about the incorrect return.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list