Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: prototype my function, please Message-ID: <246@taumet.com> Date: 5 Jun 90 16:20:22 GMT References: <1231@wet.UUCP> <0705@sheol.UUCP> <1990May31.135230.242@druid.uucp> <236@taumet.COM> <1990Jun2.091606.9125@druid.uucp> <239@taumet.COM> <16790@haddock.ima.isc.com> Reply-To: steve@taumet.UUCP (Stephen Clamage) Organization: Taumetric Corporation, San Diego Lines: 26 In article <16790@haddock.ima.isc.com> karl@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@taumet.com