Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!usc!ucsd!pacbell.com!ames!uhccux!virtue!comp.vuw.ac.nz!munnari.oz.au!mel.dit.csiro.au!yarra!melba.bby.oz.au!leo!zvs From: zvs@bby.oz.au (Zev Sero) Newsgroups: comp.lang.c Subject: Re: main() arguments, was Re: typedef-ing an array Message-ID: <1990Jul6.000337.12778@melba.bby.oz.au> Date: 6 Jul 90 00:03:37 GMT References: <78627@srcsip.UUCP> <78633@srcsip.UUCP> <25247@mimsy.umd.edu> <4238@jato.Jpl.Nasa.Gov> Sender: news@melba.bby.oz.au Organization: Burdett, Buckeridge and Young Ltd. Lines: 29 In-Reply-To: kaleb@mars.jpl.nasa.gov's message of 3 Jul 90 16:53:18 GMT In article <4238@jato.Jpl.Nasa.Gov> kaleb@mars.jpl.nasa.gov (Kaleb Keithley) writes: Furthermore, on p. 164 (Ibid.) it is stated: Within main, return expr is equivalent to exit(expr). exit has the advantage... If exit() is used rather than return, I submit that declaring main as returning type void is not only legal, but correct, as lint plus ANSI compilers will complain that there is no return statement. Precisely. Except that it is not legal to use exit(); The exit function requires an int argument, and a return from main requires the same int argument. While ANSI compilers should apparently not complain about not returning from main when exit has been used, if exit has been properly prototyped they *must* complain about calling it with no arguments. So main() must be declared int (or allowed to default to int), and the only legal ways to leave the program are exit(int); or return int; If exit is not called from main, but from elsewhere, main will require a dummy return. -- Zev Sero - zvs@bby.oz.au ...but we've proved it again and again that if once you have paid him the danegeld, you never get rid of the Dane. - Rudyard Kipling