www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/05/14:48:22

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
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: <resta-0307971339210001 AT mac-resta DOT imc DOT pi DOT cnr DOT it>
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Giovanni Resta wrote:
> 
> Recently I read in a message by John M. Aldrich" <fighteer AT cs DOT com>
> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019