Table of Contents        Previous topic       Next topic       

C/C++ COMPILER->Function Calling Conventions->CDecl Calling Convention

The __cdecl calling convention is only available when the Advanced Features of the compiler are enabled.

In the absence of the /Gr or /Gz options, __cdecl is the default calling convention.

Functions declared with the __cdecl qualifier will also use the __cdecl calling convention, overriding any /Gr or /Gz option.  The standard C library functions are declared with the __cdecl keyword.

Functions declared with an ellipsis (...) parameter will be called with the traditional calling convention.

All arguments, unless declared with the register keyword, are pushed onto the stack starting from the rightmost argument and finishing with the leftmost argument.

The arguments are popped from the stack after the called function returns.  (Caller pops stack.)

Arguments declared with the register keyword will be passed in registers if an appropriate register is available.  Integer arguments are passed in registers D1 and D0.  Pointer arguments are passed in registers A1 and A0.  If the chip has a floating point unit, floating point arguments are passed in floating point registers FP1 and FP0.  Candidate arguments for passing in registers are selected from left to right.