Archived

This topic is now archived and is closed to further replies.

FrigidHelix

WinMain

Recommended Posts

FrigidHelix    122
I have seen the return type for WinMain defined in several different ways: int APIENTRY WinMain(...) int WINAPI WinMain(...) int WinMain(...) What is the difference between these different conventions? Is it optional to use APIENTRY or WINAPI, or does it actually do something important. thx.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
APIENTRY and WINAPI are defined to be nothing. They are only there so that they could be defined as something if hte need arises.

Such an example would be to change their calling convention from __stdcall to say __cdecl.

Having them there also increases the header file and program file''s readability by letting the user know that they are entry api and windows api functions.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Um, close first Anon, but not quite. WINAPI is defined to __stdcall. This causes the parameters to be passed differently than without it specified. If it''s not there, all sorts of funny things will likely happen. In fact, in VC++, you get a warning if you don''t include it.

Share this post


Link to post
Share on other sites
Brannon    122
The reason it''s explicitly defined to __stdcall is because you can change the default calling convention on a project wide basis. So if your default calling convention is __cdecl, then any functions that aren''t explicitly tagged with a calling convention will be __cdecl. This can cause serious problems when the system code that calls WinMain expects it to be __stdcall, and it isn''t.


-Brannon

Share this post


Link to post
Share on other sites