![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Newbie
Join Date: Feb 2006
Location: India
Posts: 25
Rep Power: 0
![]() |
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! |
|
|
|
|
|
|
#2 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
From some draft of the standard I have in PDF form:
Quote:
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C# corruption!!! | Kilo | C++ | 32 | May 21st, 2006 8:44 PM |
| OOT Program Examples | Sane | Other Scripting Languages | 4 | Nov 25th, 2005 12:06 AM |
| using `char' return type in functions | atreyu | C | 6 | Jul 22nd, 2005 12:13 PM |
| Pointers in C (Part I) | Stack Overflow | C | 4 | Apr 28th, 2005 7:03 PM |
| function | solomon_13000 | Java | 6 | Apr 2nd, 2005 11:42 PM |