Geoff said:
Function main is never prototyped in any header. It's prototype is
always int main(), it always returns int by definition. It is never
called by your program. It is established as the first function called
by the runtime startup for your target environment. There can be only
one main() in your program.
The *implementation* doesn't provide a prototype for main. You're free
to do so yourself -- and in fact the usual definition of main:
int main(void) {
/* ... */
}
does provide a prototype.
It's legal to call main recursively, but it's hardly ever a good idea.
There are two correct and portable ways to define main:
int main(void) { /* ... */ }
and
int main(int argc, char *argv[]) { /* ... */ }
or equivalent.
The form without parentheses:
int main() { /* ... */ }
is at best questionable. As a non-prototype definition it uses an
*obsolescent* feature, and there's no advantage in omitting the void
keyword (which explicitly specifies that it takes no arguments).
The distinction is particularly significant if you're calling main
recursively, since the "int main(void)" form lets the compiler
diagnose calls with the wrong number of arguments.
An implementation may support other implementation-defined forms
of main. For example, I recently learned (to my dismay) that
Microsoft documents the "void main(void)" form. But there is no
good reason to use such forms; they make your program non-portable
with no real benefit. I've found that "void main(void)" is useful
mostly as an indicator that you're reading a book that was written
by someone who doesn't know C very well.
The above applies to "hosted implementations". For "freestanding
implementations" (mostly embedded systems), the program's entry
point is entirely implementation-defined; it might not even be called
"main".