Win32 Syntax Question

Feb 26, 2010 at 3:06am
Hello everyone,

In the following Win32 function, what is WINAPI?

 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int CmdShow)


I understand int is the return type and WinMain is the function name but WINAPI is throwing me off.

Thanks!!

Feb 26, 2010 at 3:44am
WINAPI is a #define for a function calling convention. probably __stdcall (but I'm too lazy to check).

Function calling conventions are something you usually don't really need to worry about unless you're trying to compile libraries or things that work with other programming languages. Basically they tell the compiler how, and in what order, the parameters are passed to the function.

WinAPI requires you be aware of calling conventions at times (like for WinMain... how it needs to be WINAPI... and window message procs needs to be CALLBACK), so just do whatever the documentation tells you, and don't sweat the details.

If you really want to learn more about calling conventions, you can can google "C/C++ Calling conventions" and find some links.
Feb 26, 2010 at 3:50am
Thank you! Now that I know what to call it, I can look it up.
Topic archived. No new replies allowed.