www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/24/13:35:29

From: XXguille AT XXiies DOT XXes (Guillermo Rodriguez Garcia)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: STL
Date: Mon, 24 May 1999 15:20:32 GMT
Organization: Telefonica Transmision de Datos
Lines: 45
Message-ID: <3749115a.750377@noticias.iies.es>
References: <373B3FD7 DOT 7D692AD2 AT alphalink DOT com DOT au> <373E8A8C DOT 87D93E54 AT earthlink DOT net> <37412752 DOT 914433 AT noticias DOT iies DOT es> <7hpdo5$m6k$1 AT news DOT doit DOT wisc DOT edu> <37497c89 DOT 11751624 AT noticias DOT iies DOT es> <199905240001 DOT UAA13489 AT envy DOT delorie DOT com>
NNTP-Posting-Host: iies240.iies.es
Mime-Version: 1.0
X-Newsreader: Forte Agent 1.5/32.451
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

El día Sun, 23 May 1999 20:01:08 -0400, DJ Delorie <dj AT delorie DOT com>
escribió:

>> After some discussion in es.lenguajes.c and es.lenguajes.c++ (spanish
>> newsgroup discussing c and c++ languajes), many people say that
>> according to the ISO standard, void main() is not incorrect, but
>> implementation dependent. That is, it is not portable, yet it is
>> allowed by the standard if the compiler chooses to support it.
>> 
>> What do you think?
>
>DJGPP's runtime code will *use* the return value of main(), so it had
>better return one.
>
>If it is "implementation defined", then for the djgpp implementation,
>I define it as returning "int", even if gcc allows otherwise.

OK, this is your decission, as you design the compiler. I just said
that it is allowed by the standar as long as the compiler chooses to
support it, not that it needs to be supported.

>My reference says that main returns "int" but if the *value* is
>undefined (i.e. it falls off the end of main without an explicit
>return), the value that is chosen as the return value is
>implementation-dependent.

This may be valid for plain C, but it does not conform to the ISO C++
standard. According to ISO 14882:1998, section 3.6.1, paragraph 5:

"A return statement in main has the effect of leaving the main
function (destroying any objects with automatic storage duration) and
calling exit with the return value as the argument. If control reaches
the end of main without encountering a return statement, the effect is
that of executing:

return 0;"

I suggest to correct this for the next version of DJGPP.

Regards,
GUILLE

----
Guillermo Rodriguez Garcia
XXguille AT XXiies DOT XXes (ya sabes :-)

- Raw text -


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