www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/04/02:54:54

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: void main ?
Date: Thu, 03 Jul 1997 17:51:40 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 34
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33BC1EEC.6B36@cornell.edu>
References: <resta-0307971339210001 AT mac-resta DOT imc DOT pi DOT cnr DOT it> <33BBB7F9 DOT 7990BD53 AT alcyone DOT com>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0011.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Erik Max Francis wrote:
> 
> Giovanni Resta wrote:
> 
> > 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)
> 
> There are only two valid ANSI C prototypes for main:
> 
>     int main(void);
>     int main(int argc, char *argv[]); /* the names of the arguments can
>                                          vary, of course */
> 
> This is clearly indicated in section 5.1.2.2.1 of the ANSI C standard.
> 

also, the draft C++ standard only specifies that the return type of main
shall be int and it should support at least the two froms given above.
so to be conforming, you must use int main (at least for hosted
applications.)

-- 
   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.
*******************************************************************

- Raw text -


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