From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Newsgroups: comp.os.msdos.djgpp Subject: Re: Main + Void Date: 14 Mar 1997 09:02:05 GMT Organization: The National Capital FreeNet Lines: 29 Message-ID: <5gb46d$gnv@freenet-news.carleton.ca> References: <01bc2f01$9891dc60$7cae71a5 AT mod DOT exo DOT com> Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) NNTP-Posting-Host: freenet3.carleton.ca To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp As an example of the pitfalls of not returning an explicit value from main: this program // mainrett.c int main (int argc, char *argv[]) { // do nothing and see what gets returned. } compiles (but has a warning, no return from function not returning void). If I run redir -x mainrett, I get this: Exit code: 2 GCC, for whatever reason, defines the implicit return value as 2. If people expect 0, a program that lets gcc choose the return value of main could break some batch files. (Don't forget what the int is *for*. It's the errorlevel. All my programs return 0 on normal exit, 1 on error like malloc failure or file not found or argument syntax error, or if arguments were expected, display a usage note and return 1, and return 255 on any protection faults, this last being dictated by CWSDPMI and not my code.) -- .*. Where feelings are concerned, answers are rarely simple [GeneDeWeese] -() < When I go to the theater, I always go straight to the "bag and mix" `*' bulk candy section...because variety is the spice of life... [me] Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh