Re: help w/ c/c++ problem
- From: Harald van Dijk <truedfx@xxxxxxxxx>
- Date: Mon, 02 Jul 2007 20:06:21 +0200
Mark McIntyre wrote:
On Sun, 01 Jul 2007 18:52:52 +0200, in comp.lang.c , Harald van D?k
<truedfx@xxxxxxxxx> wrote:
Mark McIntyre wrote:
Then I'm afraid that both your book and your teacher are wrong. The C
Standard REQUIRES main to return an int.
This is incorrect.
I should have added "for a hosted implementation".
Then it is still incorrect.
The C standard requires implementations to accept main
returning int, but does not prohibit other return types either from being
allowed by implementations or from being used by programs.
This has been done to death. For a hosted implementation, your
statement is incorrect if you want to be compliant to the standard.
5.1.2.2.1 Program startup
The function called at program startup is named main. The implementation
declares no prototype for this function. It shall be defined with a return
type of int and with no parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names
may be used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;9) or in some other implementation-defined manner.
"Or in some other implementation-defined manner" means if the implementation
documents other types for main, and you use one of these other types, the
behaviour is not undefined. If you believe the behaviour is undefined,
please list any part of the standard that is violated by
void main(void) {}
There's of course nothing stopping your implementation returning.
whatever it likes, including all your post marked "undeliverable".
However it would then not be a C compiler.
- Follow-Ups:
- Re: help w/ c/c++ problem
- From: Mark McIntyre
- Re: help w/ c/c++ problem
- From: CBFalconer
- Re: help w/ c/c++ problem
- References:
- help w/ c/c++ problem
- From: Heinrich Pumpernickel
- Re: help w/ c/c++ problem
- From: Richard Heathfield
- Re: help w/ c/c++ problem
- From: Heinrich Pumpernickel
- Re: help w/ c/c++ problem
- From: Mark McIntyre
- Re: help w/ c/c++ problem
- From: Harald van Dijk
- Re: help w/ c/c++ problem
- From: Mark McIntyre
- help w/ c/c++ problem
- Prev by Date: Re: How to check if a server is alive?
- Next by Date: Re: read from file question
- Previous by thread: Re: help w/ c/c++ problem
- Next by thread: Re: help w/ c/c++ problem
- Index(es):
Relevant Pages
|