Path: utzoo!attcan!uunet!pdn!boake2!jc3b21!fgd3 From: fgd3@jc3b21.UUCP (Fabbian G. Dufoe) Newsgroups: comp.sys.amiga Subject: Re: Lattice C 5.0 Message-ID: <532@jc3b21.UUCP> Date: 21 Dec 88 02:47:13 GMT References: <8812192102.AA25347@postgres.Berkeley.EDU> Organization: St. Petersburg Jr. College, FL Lines: 42 From article <8812192102.AA25347@postgres.Berkeley.EDU>, by dillon@POSTGRES.BERKELEY.EDU (Matt Dillon): > > You can't return an error code from main() via return. The only > way to return an error code is with exit() or _exit(). returning from main() > always generates an error code of 0. This is why main() might be declared > void. Why? Lots of people let main() fall through to exit a program, which > means the 'return value' would otherwise be garbage. Well, I used to write programs like this: main() { if (error) exit(error_code); return(0); } because main defaults to an int if you don't declare it differently and Lattice complained if I let it drop through without a return statement. It took me a little while to figure out why I couldn't do it under version 5.0. Then I changed my style to this: void main() { if (error) exit(error_code); exit(0); } It was really no problem to make the change and I'm pleased to have the compiler tighten up on questionable practices. Version 4 also defined main() as a void function in stdlib.h, but the compiler didn't care if I did it differently. --Fabbian Dufoe 350 Ling-A-Mor Terrace South St. Petersburg, Florida 33705 813-823-2350 UUCP: ...codas!usfvax2!jc3b21!fgd3 ...uunet!pdn!jc3b21!fgd3