From: Marc K. <ma...@ke...> - 2002-09-08 16:06:09
|
With all the debait about main and WinMain, I thought I'd throw this one = out there. If the following code is compiled for console, then main should be = called first. However, it the code is compiled for windows, then WinMain should be = called first. This is nothing to do with ANSI standards, it's just obviously the = programmers intentions. #include <windows.h> =20 int WINAPI WinMain(HINSTANCE , HINSTANCE , char* , int ) { MessageBox(0, "WinMain!", "Message", MB_OK); return 0; } =20 int MyDogsRealyAChickenMain() { MessageBox(0, "MyDogsRealyAChickenMain!", "Message", MB_OK); return 0; } =20 int main() { MessageBox(0, "main!", "Message", MB_OK); WinMain(0, 0, 0, 0); MyDogsRealyAChickenMain(); return 0; } If you compile this with Borland, you get what you would expect. But if = you compile it with MinGW, main is always called first. I'd be interested to know how VC++ handles this. |