From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: problems with void main(...) Date: Sat, 05 Jul 1997 14:57:27 -0400 Organization: Cornell University http://www.cornell.edu Lines: 61 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <33BE9917.2A49@cornell.edu> References: <97Jul5.182622gmt+0100 DOT 16642 AT internet01 DOT amc DOT de> Reply-To: asu1 AT cornell DOT edu NNTP-Posting-Host: cu-dialup-0002.cit.cornell.edu 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 Chris Croughton wrote: > > A. Sinan Unur wrote: > > > yep, you have missed the ansi standards. > > Where in the ANSI C standard does it say that main > must have type 'int'? I can't find it. > > It may say so in the DRAFT C++ standard, but that is > not yet approved as far as I am aware. > > Please quote the section, because I don't believe that > it was put into the ANSI C standard. this is getting ridicilously off-topic for this newsgroup. unfortunately, i do not have a copy of the actual standard at my disposal, but i hope this answer from the C faq will satisfy you. if it doesn't to heck with it, it's your problem. if you are really adamant about this, post to comp.lang.c.moderated. you can find the faq at: http://www.cis.ohio-state.edu/hypertext/faq/usenet/C-faq/faq/faq.html 11.12: Can I declare main() as void, to shut off these annoying "main returns no value" messages? A: No. main() must be declared as returning an int, and as taking either zero or two arguments, of the appropriate types. If you're calling exit() but still getting warnings, you may have to insert a redundant return statement (or use some kind of "not reached" directive, if available). Declaring a function as void does not merely shut off or rearrange warnings: it may also result in a different function call/return sequence, incompatible with what the caller (in main's case, the C run-time startup code) expects. (Note that this discussion of main() pertains only to "hosted" implementations; none of it applies to "freestanding" implementations, which may not even have main(). However, freestanding implementations are comparatively rare, and if you're using one, you probably know it. If you've never heard of the distinction, you're probably using a hosted implementation, and the above rules apply.) References: ANSI Sec. 2.1.2.2.1, Sec. F.5.1; ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p. 416; CT&P Sec. 3.10 pp. 50-51. -- Sinan ******************************************************************* A. Sinan Unur WWWWWW |--O+O mailto:sinan DOT unur AT cornell DOT edu C ^ http://www.people.cornell.edu/pages/asu1/ \ ~/ Unsolicited e-mail is _not_ welcome, and will be billed for. *******************************************************************