The standard says:
5.1.2.2.1 Program startup
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.
If I write this:
#include <stdio.h>
struct some_struct
{
int i;
};
float main(struct some_struct s)
{
printf("Why does this main get called?\n");
}
Actually, it gets called with any prototype, as I see, and there is no any runtime error.
Why isn't it forbidden? Are there no reasons for that? Also, how does it get called if the signature is wrong?
I've used gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2