cwinapimacrosstdcall

Why did Microsoft define WINAPI, CALLBACK, and APIENTRY to all refer to __stdcall?


This is a curiosity question for anybody who has worked for, known somebody who's worked for, or otherwise had any sort of affiliation with the Microsoft team responsible for defining these macros.

I understand what __stdcall is and I know why it's used, I just don't understand why Microsoft would make three separate macros for the same thing. The only benefit I could see would be to provide some semantic meaning in a source file, but other than that it provides no other benefit as far as I can tell. Obviously there was a point to doing it, I just want to know what it is! :)


Solution

  • It seems you're right about the different macros being used to provide semantic information. MSDN says this about CALLBACK:

    CALLBACK, WINAPI, and APIENTRY are all used to define functions with the __stdcall calling convention. Most functions in the Windows API are declared using WINAPI. You may wish to use CALLBACK for the callback functions that you implement to help identify the function as a callback function.

    Both WINAPI and APIENTRY are said to be:

    The calling convention for system functions.

    I don't know why there's two macros for system functions.