From: Marc K. <ma...@ke...> - 2002-09-08 19:29:17
|
Yes John, you do understand. But I think we disagree on which behaviour is correct. In my opinion, if you target a program for windows, then it should start as the Win32 API says it should: ie. with WinMain. A windows program shouldn't have a choice between main and WinMain. Having said that, I do think it's very convenient not having to type a full WinMain for quick programs, and as long as the WinMain paramaters are correct, I'm sure it would very rarely be a problem. Marc. ----- Original Message ----- From: "John Cronin" <jo...@st...> To: <min...@li...> Sent: Sunday, September 08, 2002 8:02 PM Subject: RE: [Mingw-users] main of WinMain > If what I understand of the past discussion is correct (and probably isn't > :) ), the MinGW result seems the 'correct' one. > > My understanding is: > > If a program (any program) contains a 'main', that is executed. > If it doesn't: > - And the program is compiled for Win32 (-mwindows), then a stub make is > put in (called main) which calls WinMain with the correct arguments (along > with setting up instances and other things I presume) > - And the program _isn't_ compiled for Win32, there is nothing put in and > so no main function. > > And if no main is defined at link-time, you get a link error(/warning). > > John. > > -----Original Message----- > From: min...@li... > [mailto:min...@li...]On Behalf Of Marc Kealy > Sent: 08 September 2002 17:01 > To: Min...@li... > Subject: [Mingw-users] main of WinMain > > > 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> > > int WINAPI WinMain(HINSTANCE , HINSTANCE , char* , int ) > { > MessageBox(0, "WinMain!", "Message", MB_OK); > return 0; > } > > int MyDogsRealyAChickenMain() > { > MessageBox(0, "MyDogsRealyAChickenMain!", "Message", MB_OK); > return 0; > } > > 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. > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > |