Friday, May 11, 2012

Calling conventions for functions: __cdecl, __stdcall, __fastcall, WINAPI, etc

1. Links

Calling Conventions Demystified: http://www.codeproject.com/Articles/1388/Calling-Conventions-Demystified


Conclusion
To cut a long story short, we'll outline the main differences between the calling conventions:
  • __cdecl is the default calling convention for C and C++ programs. The advantage of this calling convetion is that it allows functions with a variable number of arguments to be used. The disadvantage is that it creates larger executables.
  • __stdcall is used to call Win32 API functions. It does not allow functions to have a variable number of arguments.
  • __fastcall attempts to put arguments in registers, rather than on the stack, thus making function calls faster.
  • Thiscall calling convention is the default calling convention used by C++ member functions that do not use variable arguments.




No comments:

Post a Comment