### __stdcall Calling Convention

To use this linkage convention, use the __stdcall keyword in the declaration of the function. You can make __stdcall the default linkage by specifying the /Mt compiler option.

The following rules apply to the __stdcall calling convention:

- All parameters are passed on the stack.
- The parameters are pushed onto the stack in a lexical right-to-left order.
- The called function removes the parameters from the stack.
- Floating point values are returned in ST(0), the top register of the floating point register stack. Functions returning non-floating point values return them as follows:
  Size of Aggregate
    Value Returned in
  8 bytes
    EAX-EDX pair
  5, 6, 7 bytes
    EAX The address to place the return values is passed as a hidden parameter in EAX.
  4 bytes
    EAX
  3 bytes
    EAX The address to place the return values is passed as a hidden parameter to EAX.
  2 bytes
    AX
  1 byte
    AL

  For functions that return aggregates 5, 6, 7 or more than 8 bytes in size, the address to place the return values in is placed as a hidden parameter and the address is passed back in EAX.

- An unprototyped __stdcall function with a variable number of arguments will not work.
- Function names are decorated with an underscore prefix, and a suffix which consists of an at (@), followed by the number of bytes of parameters (in decimal). Parameters of less than four bytes are rounded up to four bytes. Structure sizes are also rounded up to a multiple of four bytes. For example, a function fred prototyped as follows:

        int fred(int, int, short);

  would appear as:

        _fred@12

  in the object module.

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.

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 the ILIB utility along with the module definition file. ILIB will use the object files to determine how each name ended up after decoration.

Examples Using the __stdcall Convention
ILIB Objects