Im reading some of the game fix codes which deal with memory manipulation to fix a game's "issue". I found out that the code uses 2 macros that are WINAPI
and STDMETHODCALLTYPE
. These macros all get evaluated into __stdcall
which specifies the calling convention for a function. I also found out that APIENTRY
is also another macro alias for WINAPI
. So are there any differences between these macros ? It seems to me that they are just aliases. Why are there so many of them ?
All data types and calling conventions in the Windows API are defined as aliases (preprocessor macros or typedef
s). This allows for a stable ABI, irrespective of the compiler or toolchain. It also allows to change the ABI without breaking existing code (e.g. when 64-bit Windows was introduced).
Both WINAPI
and STDMETHODCALLTYPE
expand to the same thing: __stdcall
for x86 and nothing for everything else. So why have 2 aliases for the same thing then? Because they control the calling convention for different subsets:
WINAPI
specifies the calling convention for the flat C-based Windows API.STDMETHODCALLTYPE
, on the other hand, controls the calling convention for COM (Component Object Model).COM and the Windows API are independent. Having 2 aliases to control the calling convention for either makes perfect sense. You wouldn't want to break all COM, just because you're moving to a new ABI for Win128.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With