Mail Archives: djgpp/1997/05/10/12:53:35
A. Sinan Unur wrote:
> first, this is pure and simple C. in any case, void is not a valid
> return type for main.
Incorrect. Void is a perfectly good return type for main.
> main has to return an int.
No it doesn't. It only needs to generate any specific exit value
if you will be using the result to test the state of the program
afterwards (like in make or with the batch ERRORLEVEL). And even
then it's perfectly valid to use exit(n) rather than return. Since
many compilers complain if there is no return with a value from
a non-void function, if the program is known to always use exit()
or be non-terminating it is often better to declare main as void
to get rid of the warnings.
It may be considered, in some places, good /style/ to declare main
as int, but that's a long way from it being an absolute.
Even with -Wall -ansi -pedantic I can't get gcc to complain about
void main...
Chris
- Raw text -