The ATTRIBUTES directive options C and STDCALL specify how data is to be passed when you use routines written in C or assembler with FORTRAN or Fortran 95/90 routines. They take the following forms:
On IA-32 architecture, C and STDCALL have slightly different meanings; on all other platforms, they are interpreted as synonyms.
When applied to a subprogram, these options define the subprogram as having a specific set of calling conventions.
The following table summarizes the differences between the calling conventions:
Convention | C 1 | STDCALL 1 | Default 2 |
---|---|---|---|
Arguments passed by value | Yes | Yes | No |
Case of external subprogram names | L*X, M*X: Lowercase W*32, W*64: Lowercase |
L*X, M*X: Lowercase W*32, W*64: Lowercase |
L*X, M*X: Lowercase W*32, W*64: Uppercase |
L*X, M*X only: | |||
Trailing underscore added | No | No | Yes 3 |
M*X only: | |||
Leading underscore added | No | No | Yes |
W*32 only: | |||
Leading underscore added | Yes | Yes | Yes 4 |
Number of arguments added | No | Yes | No |
Caller stack cleanup | Yes | No | Yes |
Variable number of arguments | Yes | No | Yes |
1 C and STDCALL are synonyms on Linux systems. 2 The Intel Fortran calling convention 3 On Linux systems, if there are one or more underscores in the external name, two trailing underscores are added; if there are no underscores, one is added. 4 W*32 only |
If C or STDCALL is specified for a subprogram, arguments (except for arrays and characters) are passed by value. Subprograms using standard Fortran 95/90 conventions pass arguments by reference.
On IA-32 architecture, an underscore ( _ ) is placed at the beginning of the external name of a subprogram. If STDCALL is specified, an at sign (@) followed by the number of argument bytes being passed is placed at the end of the name. For example, a subprogram named SUB1 that has three INTEGER(4) arguments and is defined with STDCALL is assigned the external name _sub1@12.
Character arguments are passed as follows:
See Also