IntelĀ® Fortran Compiler 18.0 Developer Guide and Reference
The ATTRIBUTES directive options C and STDCALL specify procedure calling, naming, and argument passing conventions.
!DIR$ ATTRIBUTES C :: object[, object] ...
!DIR$ ATTRIBUTES STDCALL :: object[, object] ...
object |
Is the name of a data object or procedure. |
On Windows* systems on IA-32 architecture, C and STDCALL have slightly different meanings; on all other platforms, STDCALL is treated as C.
When applied to a subprogram, these options define the subprogram as having a specific set of calling conventions. The effects depend on whether or not the subprogram is interoperable (has the BIND attribute).
For interoperable subprograms with the BIND attribute, ATTRIBUTES STDCALL has the following effects for subprograms in applications targeting Windows systems on IA-32 architecture:
The STDCALL calling convention is used where the called subprogram cleans up the stack at exit.
The external name has @n appended, where n is the number of bytes of arguments pushed on the stack.
No other effects of ATTRIBUTES STDCALL are applied for interoperable subprograms. If pass-by-value is desired for a dummy argument to an interoperable subprogram, the Fortran standard VALUE attribute should be specified for that argument.
For platforms other than Windows systems on IA-32 architecture, ATTRIBUTES STDCALL has no effect on interoperable subprograms. You should not specify ATTRIBUTES C for interoperable subprograms.
The following table and subsequent text summarizes the differences between the calling conventions for subprograms that are not interoperable:
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*S: Lowercase |
L*X, M*X: Lowercase W*S: Lowercase |
L*X, M*X: Lowercase W*S: Uppercase |
L*X, M*X only: |
|||
Trailing underscore added |
No |
No |
Yes3 |
M*X only: |
|||
Leading underscore added |
No |
No |
Yes |
W*S only: |
|||
Leading underscore added |
Yes |
Yes |
Yes4 |
Number of argument bytes added to name |
No |
Yes |
No |
Caller stack cleanup |
Yes |
No |
Yes |
Variable number of arguments |
Yes |
No |
Yes |
1STDCALL is treated as C on Linux*, macOS*, and on Windows* on Intel® 64 architecture. 2The Intel® Fortran calling convention 3On Linux, if there are one or more underscores in the external name, two trailing underscores are added; if there are no underscores, one is added. 4IA-32 architecture only |
If C or STDCALL is specified for a subprogram, arguments (except for arrays and characters) are passed by value. Subprograms using standard Fortran 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:
By default, hidden lengths are put at the end of the argument list.
On Windows* systems using IA-32 architecture, you can get Compaq* Visual Fortran default behavior by specifying compiler option iface.
If C or STDCALL (only) is specified:
On all systems, the first character of the string is passed (and padded with zeros out to INTEGER(4) length).
If C or STDCALL is specified, and REFERENCE is specified for the argument:
On all systems, the string is passed with no length.
If C or STDCALL is specified, and REFERENCE is specified for the routine (but REFERENCE is not specified for the argument, if any):
On all systems, the string is passed with the length.
Compiler Reference section: Mixed Language Programming