why do this

Started by
2 comments, last by Muhammad Haggag 18 years, 10 months ago
#define STDMETHODCALLTYPE __stdcall _stdcall is readable.
Advertisement
Doing that simply creates an alias for __stdcall. Allowing you to write STDMETHODCALLTYPE or __stdcall in any place you would use __stdcall. If you have ever wrote a WinMain then you may of used "int WINAPI WinMain(...)", WINAPI is an alias to a calling convention defined in the same was as you have shown.

Basically it's just an alias and there are many reasons for using it. A few reasons could be: Giving it a more descriptive name, Keeping consistant naming in a library of some sort, Personal preference..
Progress is born from the opportunity to make mistakes.

My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
I think one of the primary reasons is that they can change the calling convention if they ever need to.

_stdcall has a well defined meaning (not sure if it's actually an ISO-C++ keyword tho?) thus they couldn't easily change it.

Conversely, if you have STDMETHODCALLTYPE and everyone uses it, they could change just the one #define and force a recompile and voila! all sorted. Examples of this might be an optimization (or debug) switch or maybe a platform switch (e.g. Win32->Win64)...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by jollyjeffers
_stdcall has a well defined meaning (not sure if it's actually an ISO-C++ keyword tho?) thus they couldn't easily change it.

All identifiers starting with double underscores are vendor-specific extensions.

This topic is closed to new replies.

Advertisement