Russell Nelson <[EMAIL PROTECTED]> writes:
> It's of no concern. At some point, some smart person decided that main
> should return the exit code of the program. So every program needed to
> have its 'main' routine changed from void to int,
Mm... I'm fairly certain that it's been int main() clear back to the K&R
days. I don't have a 1st edition K&R handy, but the second edition
declares main without a return value, which in C of course is an implicit
declaration of int.
> and have the final exit(x) changed to return(x).
This is certainly not necessary. No standard requires it that I've ever
seen, and current gcc has no problems with it.
windlord:/tmp> cat test.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello, world!\n");
exit(0);
}
windlord:/tmp> gcc -W -Wall -o test test.c
windlord:/tmp> ./test
Hello, world!
windlord:/tmp> gcc -v
Reading specs from /usr/pubsw/lib/gcc-lib/sparc-sun-solaris2.6/2.95.1/specs
gcc version 2.95.1 19990816 (release)
Older gcc's didn't know that exit doesn't return, and therefore would warn
about main without a return with warnings enabled, but that's been fixed.
I'm not even sure how long ago.
--
Russ Allbery ([EMAIL PROTECTED]) <URL:http://www.eyrie.org/~eagle/>