The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bf2 on July 01, 2011, 10:36:35 AM

Title: The WINAPI token
Post by: bf2 on July 01, 2011, 10:36:35 AM
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.

Title: Re: The WINAPI token
Post by: Tedd on July 01, 2011, 12:38:40 PM
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.
Title: Re: The WINAPI token
Post by: drizz on July 01, 2011, 12:39:41 PM
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).