Path: utzoo!attcan!uunet!aplcen!samsung!cs.utexas.edu!rutgers!mcnc!rti!dg-rtp!larrybud.rtp.dg.com!goudreau From: goudreau@larrybud.rtp.dg.com (Bob Goudreau) Newsgroups: comp.lang.c Subject: Re: main() arguments, was Re: typedef-ing an array Message-ID: <1990Jul6.160121.1119@dg-rtp.dg.com> Date: 6 Jul 90 16:01:21 GMT References: <4238@jato.Jpl.Nasa.Gov> <25273@mimsy.umd.edu> <4241@jato.Jpl.Nasa.Gov> <2160@polari.UUCP> <4249@jato.Jpl.Nasa.Gov> <1990Jul5.221205.19888@dg-rtp.dg.com> <4254@jato.Jpl.Nasa.Gov> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Reply-To: goudreau@larrybud.rtp.dg.com (Bob Goudreau) Organization: Data General Corporation, Research Triangle Park, NC Lines: 54 In article <4254@jato.Jpl.Nasa.Gov>, kaleb@mars.jpl.nasa.gov (Kaleb Keithley) writes: > > > >> It also strikes me that what may be missing from the standard is a statement > >> along the lines of "... use of exit() from main() is illegal..." Not to > >> mention that K&R2 is a little misleading in this area also. > > > >Say what? Who has ever claimed that use of exit() from main() is not > >legal? > > I don't think anyone ever said it was illegal. Then why does it strike you that such a statement is missing from the standard? > By implication I was trying to state that the use of exit() from > (ANSI Std. C defined): > int main(int argc; char **argv) { ... } > was inconsistant. Maybe I'm picking nits, but main() should use return > instead of exit based on this. If the ANSI Std. is going to define a > the way that main() is declared, then they should define the corresponding > exit (not the funcion) from function main(). And IMHO, return is the > correct exit method from int main(). > > if main() is defined as returning a value of type int, then the use of > exit is not consistant with the defined return value of the function. > .... > Furthermore, had you read my (and others) previous posting on this subject, > you'd have seen my reference to K&R2 that stated that exit() from main() > and return from main() were equivalent. But, as you mention, the standard explicitly states that the two methods are *equivalent* (see excerpt below), so in what way is the standard inconsistent? It says essentially, "you can do it this way or you can do it that way, but both of those ways are equivalent". 2.1.2.2.3 Program Termination A return from the initial call to the |main| function is equivalent to calling the |exit| function with the value returned by the |main| function as its argument. If the |main| function executes a return that specifies no value, the termination status returned to the host environment is undefined. ------------------------------------------------------------------------ Bob Goudreau +1 919 248 6231 Data General Corporation 62 Alexander Drive goudreau@dg-rtp.dg.com Research Triangle Park, NC 27709 ...!mcnc!rti!xyzzy!goudreau USA