Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!taumet!steve From: steve@taumet.COM (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: prototype my function, please Message-ID: <239@taumet.COM> Date: 4 Jun 90 16:03:47 GMT References: <1231@wet.UUCP> <0705@sheol.UUCP> <1990May31.135230.242@druid.uucp> <236@taumet.COM> <1990Jun2.091606.9125@druid.uucp> Reply-To: steve@taumet.UUCP (Stephen Clamage) Organization: Taumetric Corporation, San Diego Lines: 30 In article <1990Jun2.091606.9125@druid.uucp> darcy@druid.UUCP (D'Arcy J.M. Cain) writes: > ... >#include >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@taumet.com