![]() |
Return type - main() / ISO C standard
The ISO C++ standard clearly wants the return type of main to be int, so there is no conflict there.But quoting from the link given below,ISO C standard doesn't say so :
Quote:
I completely understand that void main() is EVIL anyways but please clarify the issue as per the C standard! |
From some draft of the standard I have in PDF form:
Quote:
|
There are some people who quibble over the placement of a semi-colon in the C standard, claiming that the way it is placed allows main() to be implemented in ways other than returning int. The people who do that are attempting to say that main() not returning int is still standard C. They are talking from their nether regions.
The C and C++ standards are worded differently (mainly because the C++ standard has to be unambiguous and prevent things like overloading of main() by a programmer). However, both are quite clear in requiring compilers to support main() in both the "int main()" and "int main(int argc char *argv[])" [or equivalent] forms, and that any other form of main() is implementation defined behaviour. Which means that both C and C++ compilers are required to support the int main() forms, or they cannot be described as standard compliant. Other forms represent implementation defined behaviour: a compiler is allowed to support any form of main() it wishes as long as it also supports the two int forms. User code, on the other hand, cannot be compliant with the standard if it uses any form of main() other than the int forms. In english, this means that code which uses any form of main, other than the two int forms, is compiler specific. |
| All times are GMT -5. The time now is 2:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC