News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

The WINAPI token

Started by bf2, July 01, 2011, 10:36:35 AM

Previous topic - Next topic

bf2

Posted this at a different site, posting here as well because I didn;t get any response there.

What kind of token is WINAPI, that appears before every Windows function. I know it stands for __stdcall, and I know about calling conventions. But I have never known C language to allow a calling convention descriptor to sit between the function name (WinMain) and the return type (int):
i.e. int WINAPI WinMain (...)

So how exactly does this work? I even had a look at the C99 specification but couldn't find anything similar there.


Tedd

It's nothing special, just a pre-processor definition as part of the windows headers.

#define WINAPI __stdcall


It's for readability more than anything - CALLBACK and APIENTRY are exactly the same - it's simply code documentation.


How you specify the calling-convention depends on your compiler; since it's usually __cdecl there's rarely need to change it.
No snowflake in an avalanche feels responsible.

drizz

It's an extension. Standard C without extensions is practically unusable. Just look here http://msdn.microsoft.com/en-US/library/634ca0c2(v=VS.80).aspx and count the functions starting with an underscore, those functions are also non-standard (i.e. an extension).
The truth cannot be learned ... it can only be recognized.