For example:
int WINAPI WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show )
WINAPI is a a define that looks like this:
#define WINAPI __stdcall
why can’t you just do:
int __stdcall WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show )
actually I think my problem is that I’m sort of confusing defines with typedef’s. Can someone explain this to me? what does the define do and why can’t you just write __stdcall in its place?
Because the
WINAPIcalling convention is not guaranteed to be__stdcall. Code that usesWINAPIwill still be correct even when it isn’t.You can write the function as in your latter example, and it’d work fine – it’s just not good practice and would not be portable to a platform where the calling convention is something else.