Jump to content
  • Advertisement
Sign in to follow this  
mashrub

int XXX WinMain

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

int WINAPI WinMain // ...
int PASCAL WinMain // ...
Hello, I'd like to know what do the "WINAPI" and "PASCAL" things mean and what purpose they serve. Are there any other like these? Thanks for your replies!

Share this post


Link to post
Share on other sites
Advertisement
They are macros that (should) evaluate to something like __declspec(stdcall), specifying the calling convention that is standard to the Windows API.

See here for more.

edit: linked to MSDN rather than Wikipedia.

Share this post


Link to post
Share on other sites
Hey, thanks for that!
Now, I'd like to know something else: is it compulsory to tell the compiler the calling convention of the WinMain function?

Share this post


Link to post
Share on other sites
I "think" (and by think I mean am possibly talking out of the left edge of my ass) that it is there to tell certain Non-VS compilers what the convention is. In Visual Studio, it can be left out without any (that I know of) effect whatsoever.

Share this post


Link to post
Share on other sites
In the project settings, you can set the default calling convention. I believe the default is cdecl, so if you need stdcall or something else, you'll either have to manually specify the alternate calling convention wherever you need it, or you will have to change the project-wide calling convention and use that everywhere (or manually specify cdecl when you want it).

Share this post


Link to post
Share on other sites
Generally it's best to leave your project settings alone and just specify WINAPI before things like WinMain() and your window procedures.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don't know if including the calling convention is necessary (it may well be depending on your compiler), but I believe including it explicitly the declaration is just good form.

Share this post


Link to post
Share on other sites
Quote:
Original post by JBourrie
I "think" (and by think I mean am possibly talking out of the left edge of my ass) that it is there to tell certain Non-VS compilers what the convention is. In Visual Studio, it can be left out without any (that I know of) effect whatsoever.


Not completely true. If you don't tell the calling convention, the compiler assume that you use the c calling convention - which is different from the stdcall one. Most WinAPI callbacks are supposed to be stdcall - if you feed a function with a callback that is not stdcall, you'll probably going to screw your stack and to crash.

Regards,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!