Mail Archives: djgpp/1997/05/11/22:04:33
> > 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.
Wrong wrong wrong... you must return int...
> > 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.
What if another program not written by yourself requires your program
to return a value, and you haven't written one, you are restricting
portability... no? You _must_ return a value, even if you don't see it
as obvious as to why...
> 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.
No, it is absolute.
> Even with -Wall -ansi -pedantic I can't get gcc to complain about
> void main...
So? There are probably a lot of things you can do that can cause problems
which don't pop up in the compiler... basically, if the ansi doc says
you should do it a certain way, then you should do it that way...
Leathal.
- Raw text -