Hacker News new | past | comments | ask | show | jobs | submit login

> Also, TIL according to the C standard, 'main' is not a reserved identifier! (https://stackoverflow.com/questions/34764796/why-does-declar...)

That's not quite true.

Main is not required to be defined in a freestanding environment, but in a hosted environment:

> 5.1.2.2.1 Program startup

> 1

> The function called at program startup is named

> main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters:

    int main(void) { /* ... */ }
> or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared):

    int main(int argc, char *argv[]) { /* ... */ }
> or equivalent; 10) or in some other implementation-defined manner.

main can take on differing types, but it then becomes undefined-behaviour, which allows the compiler to do whatever it wants.

(5.1.2.2.1 Program startup, C11 Standard http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf)




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: