Mail Archives: djgpp/1999/05/24/13:35:29
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 -