Win32 Return Types
I've noticed that some Win32 functions seem to have two return types, like:
int WINAPI WinMain...
and
LRESULT CALLBACK WinProc...
I'm pretty sure that the second "return types" aren't really return types, but if they're not, what are they? I've never seen two words preceding a function name outside of Win32.
The return types of those functions are int and LRESULT, respectively.
The 'keywords' WINAPI and CALLBACK indicate the calling convention used. The calling conventions describes how arguments are placed on the stack, and which registers of the CPU must be preserved.(More info: Wikipedia: x86 calling conventions). Note that WINAPI and CALLBACK actually are #defines for (OTOH) __stdcall and __cdecl.
The 'keywords' WINAPI and CALLBACK indicate the calling convention used. The calling conventions describes how arguments are placed on the stack, and which registers of the CPU must be preserved.(More info: Wikipedia: x86 calling conventions). Note that WINAPI and CALLBACK actually are #defines for (OTOH) __stdcall and __cdecl.
CALLBACK, WINAPI, PASCAL, and probably a few more that I cant remember right now are all #defined as __stdcall. None of them are #defined as __cdecl.
My understanding is that cdecl is the default - "C decl". This, Calling Conventions Demystified, claims it's the default for C and C++.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement