|
|
|
|
|
by boblivion
2214 days ago
|
|
Which is funny because the void keyword specifies that the function receives no arguments. Otherwise you could call it with any amount of arguments you want.
However, the linker doesn't care about type-signatures, so in the end this main function still gets called with argc, argv, envp. |
|
The C standard specifies (for hosted implementations) two ways to define "main", and allows implementations to document and support more. "int main(void)" is one of them. "int main()" is not. So, strictly speaking, using "int main()" makes your program's behavior undefined.
On the other hand, as far as I know every implementation actually allows "int main()" with no problem. This was necessary to support pre-ANSI C code, which couldn't use the "void" keyword. It's still better to be explicit and use "int main(void)" rather than "int main()". (It can also affect recursive calls to main, which are legal but almost certainly a bad idea.)