From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: void main ? Date: Thu, 03 Jul 1997 09:40:34 -0400 Organization: Cornell University Lines: 35 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <33BBABD2.3249@cornell.edu> References: NNTP-Posting-Host: 128 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Giovanni Resta wrote: > > Recently I read in a message by John M. Aldrich" > that declaring the main as void, instead of int can produce > unpredictable nasty effects. > > I always declared main as void in the past 5 years and > I never get an error, so I'm curious about the topic. > (I must admit that I never had to test the 'exit code' of a program, > maybe that can change things) > trolls. what would life be like without them! please refer to the ANSI/ISO C standard and the C FAQ. the latter is available at: http://www.cis.ohio-state.edu/hypertext/faq/usenet/C-faq/faq/faq.html the sections of interest are: 11.12: Can I declare main() as void, to shut off these annoying "main returns no value" messages? 11.14: I believe that declaring void main() can't fail, since I'm calling exit() instead of returning, and anyway my operating system ignores a program's exit/return status. 11.15: The book I've been using, _C Programing for the Compleat Idiot_, always uses void main(). 11.16: Is exit(status) truly equivalent to returning the same status from main()? -- Sinan