Mail Archives: djgpp/1996/07/05/21:46:49
In article <4qu19j$d5v AT hagar DOT cyberoptics DOT com>
rudd AT cyberoptics DOT com "Eric Rudd" writes:
> In section 5.1.2.2.3, the ANSI document states "If the main function
> executes a return that specifies no value, the termination status
> returned to the host environment is undefined." It is therefore implied
> that "void main" is not an error.
From my experience on comp.lang.c, you are misreading this. The paragraph
means that if you just fall off the end of main(), without using return
or exit(), *then* the return value is undefined. This is different from
the undefined *behaviour* of void main. The first can make your OS do
funny things, the second your program.
Consider this excerpt from <http://www.lysator.liu.se/c/schildt.html>
----- 8< -----
(standard)
"You are therefore free to declare main() as required by your program."
(critique of schildt)
This statement is immediately followed by the example:
void main (void)
even though the text of the standard directly opposite states that this is
undefined. Indeed, the text I quote makes me wonder whether Schildt believes
that:
struct foo { int i; double d; } main (double argc, struct foo argv)
is permitted !
----- 8< -----
..splitbung
--
* TQ 1.0 * The 'Just So Quotes'.
"I'm a paranoid agnostic. I doubt the existence of God, but I'm sure there is
some force, somewhere, working against me." --Marc Maron
- Raw text -