News for hackers. Stuff that matters.
Re:C++ main function doesn't need return but has int return ... by eesmith on Wednesday January 29, 2025 @05:27AM (#42863454)
I'm pretty sure main is supposed to be declared with an int return type, but the compiler may specify something else.

My reading of https://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf says the C99 spec requires "int main(void)", "int main(int argc, char *argv[])" or "some other implementation-defined manner".

There's also the clause that if the type is compatible with int then "reaching the } that terminates the main function returns a value of 0.".

In other words, C implicitly adds return 0 if missing (and appropriate).

There are no comments on this comment yet.