To use this linkage convention, use the __cdecl keyword in the declaration of the function. You can make __cdecl the default linkage by specifying the call Code Generation option (gen(call,cdecl)) when you invoke the compiler.
The
__cdecl linkage is very similar to the OS/2 __System linkage
convention. All general purpose registers are preserved except
for EAX, ECX, and EDX. Note that, unlike the OS/2 _System
linkage, the number of dwords used to store parameters is not
passed in AL. The parmdwords builtin function does not apply to
__cdecl.
The following rules apply to the __cdecl calling convention:
For functions that return aggregates greater than four bytes in size, the address to place the return values is passed as a hidden parameter, and the addresss is passed back in EAX.
When
building export or import lists in module definition files, the
decorated version of the name should be used. This is
automatically handled when using #pragma export and #pragma
import. If you use undecorated names in the module definition
file, you must give the object files to ILIB along with the
module definition file. ILIB will use the object files to
determine how each name ended up after decoration.
When
building export or import lists in module definition files, the
decorated version of the name should be used. This is
automatically handled when using #pragma export and #pragma
import.
Note
that when the parmdword
Code Generation Option is on and this function calls the
__parmdwords function, the value of AL is stored in a temporary
variable in its prolog. This is done to ensure that the value
cannot change before the call to __parmdwords.
![]()
Examples Using the _cdecl
Calling Convention
