__fastcall

Switch View :
ScriptFree
Visual Studio 2010 - Visual C++
__fastcall

Microsoft Specific

The __fastcall calling convention specifies that arguments to functions are to be passed in registers, when possible. The following list shows the implementation of this calling convention.

Element

Implementation

Argument-passing order

The first two DWORD or smaller arguments are passed in ECX and EDX registers; all other arguments are passed right to left.

Stack-maintenance responsibility

Called function pops the arguments from the stack.

Name-decoration convention

At sign (@) is prefixed to names; an at sign followed by the number of bytes (in decimal) in the parameter list is suffixed to names.

Case-translation convention

No case translation performed.

NoteNote

Future compiler versions may use different registers to store parameters.

Using the /Gr compiler option causes each function in the module to compile as fastcall unless the function is declared with a conflicting attribute, or the name of the function is main.

On Itanium Processor Family (IPF) and AMD64 machines, __fastcall is accepted and ignored by the compiler; on an IPF chip, by convention, parameters are passed in register.

For non-static class functions, if the function is defined out-of-line, the calling convention modifier does not have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition. Given this class definition,

struct CMyClass {
   void __fastcall mymethod();
};

this

void CMyClass::mymethod() { return; }

is equivalent to this

void __fastcall CMyClass::mymethod() { return; }
Example

In the following example, the function named DeleteAggrWrapper is passed arguments in registers:

// Example of the __fastcall keyword
#define FASTCALL    __fastcall
   
void FASTCALL DeleteAggrWrapper(void* pWrapper);
// Example of the __ fastcall keyword on function pointer
typedef BOOL (__fastcall *funcname_ptr)(void * arg1, const char * arg2, DWORD flags, ...);

See Also

Reference

Community Content

Chuck Walbourn - MSFT
SSE

It's not noted here or in the docs, but was noted in the original VC release notes, but the the first THREE __m64 or __m128 values are passed in-register on 32-bit (x86) as well as the use of ECX/EDX above for DWORD-sized parameters.

http://software.msu.montana.edu/free/Microsoft/Updates/Visual_Studio/sp5/PP/ppreadme.htm

 


wangqi
__fastcall can handle with vararg functions???

In the Example section, we can see:

// Example of the __ fastcall keyword on function pointer
typedef BOOL (__fastcall *funcname_ptr)(void * arg1, const char * arg2, DWORD flags, ...);

Under __fastcall, The callee cleans the stack, vararg functions cannot be made. 

So, is there something wrong with the example above?