[In Windows Programming,] Why wasn't the application entry point called
main? Well, for one thing, the name main was already taken, and
Windows didn't have the authority to reserve an alternate definition.
There was no C language standardization committee back then; C was
what Dennis said it was, and it was hardly guaranteed that Dennis
would take any special steps to preserve Windows source code
compatibility in any future version of the C language. Since K&R
didn't specify that implementations could extend the acceptable forms
of the main function, it was entirely possible that there was a legal
C compiler that rejected programs that declared main incorrectly. The
current C language standard explicitly permits implementation-specific
alternate definitions for main, but requiring all compilers to support
this new Windows-specific version in order to compile Windows programs
would gratuitously restrict the set of compilers you could use for
writing Windows programs.
If you managed to overcome that obstacle, you'd have the problem that
the Windows version of main would have to be something like this:
int main(int argc, char *argv[], HINSTANCE hinst,
HINSTANCE hinstPrev, int nCmdShow);
Due to the way C linkage was performed, all variations of a function had to agree on the
parameters they had in common. This means that the Windows version
would have to add its parameters onto the end of the longest existing
version of main, and then you'd have to cross your fingers and hope
that the C language never added another alternate version of main. If
you went this route, your crossed fingers failed you, because it turns
out that a third parameter was added to main some time later, and it
conflicted with your Windows-friendly version.
Suppose you managed to convince Dennis not to allow that
three-parameter version of main. You still have to come up with those
first two parameters, which means that every program's startup code
needs to contain a command line parser. Back in the 16-bit days,
people scrimped to save every byte. Telling them, "Oh, and all your
programs are going to be 2KB bigger" probably wouldn't make you a lot
of friends. I mean, that's four sectors of I/O off a floppy disk!
But probably the reason why the Windows entry point was given a
different name is to emphasize that it's a different execution
environment. If it were called main, people would take C programs
designed for a console environment, throw them into their Windows
compiler, and then run them, with disastrous results.