Saturday, May 28, 2016

Calling Convention in C and C++

Calling Convention in C and C++

Calling Conventions:

Keyword Remarks
__cdecl Default calling convention for C and C++ programs.
__stdcalll Used to call win32 API functions.
__fastcall Argument to functions are to be passed in register when possible.
thiscall Default calling conventions used by C++ member functions that do not use variable arguments. It is not explicitly defined in a program, because it is not a keyword.


Keyword Stack Cleanup Parameter Passing
__cdecl Caller R To L
__stdcalll Callee R To L
__fastcall Callee Stored in registers, then pushed on stack
thiscall Callee Pushed on stack, this pointer stored in ECX

Note: __cdeclspec (extended attribute) declarator

If specifies that an instance of a given type is to be stored with a Microsoft specific storage class attribute.

No comments:

Post a Comment