Replacing main()

Started by
13 comments, last by Densun 22 years, 4 months ago
Oh yeah, and if you think it''s bad they replaced main() with WinMain(), what about MFC which doesn''t have a "main" function at all!

codeka.com - Just click it.
Advertisement
Grrrr...didnt anyone read that passage from the standard I quoted? Its perfectly legal for a ''freestanding environment'' to define its own entry point.
And I think the suggestion that this is some sort of attempt to tie people into using Microsoft technology is just silly. The moment you start writing code that requires a WinMain, you are already writing platform dependent code. You cannot get Win32-specific code to compile under any other platform anyway, WinMain or no WinMain.

Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:what about MFC which doesn''t have a "main" function at all!


Yes it does it has two. A WinMain() that calls AfxWinMain(). Try running a MFC app through a debugger.
quote:Original post by coderx75
Sure, but my point and I would guess Densun''s point is why change the main() function? Obviously, so that MS can tie people into their compiler.

*Ahem*

Their compiler? That would seem to suggest that a Windows application written to use WinMain would not compile under any other compiler - clearly false given the abundance of available Win32 development environments.

The question is moot, the discussion is moot. The more interesting question is why it irks you.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
Regardless of whether MS wants to ''lock you in'' to using their compiler, WinMain has the following signature:

int WINAPI WinMain(  HINSTANCE hInstance,  // handle to current instance  HINSTANCE hPrevInstance,  // handle to previous instance  LPSTR lpCmdLine,      // pointer to command line  int nCmdShow          // show state of window); 

Which obviously has different requirements to main(). So simply using ''main'' would not be easy.

This topic is closed to new replies.

Advertisement