The ATTRIBUTES directive options C and STDCALL specify procedure calling, naming, and argument passing conventions. They take the following forms:
cDEC$ ATTRIBUTES C :: object[, object] ...
cDEC$ ATTRIBUTES STDCALL :: object[, object] ...
c |
Is one of the following: C (or c), !, or *. (See Syntax Rules for Compiler Directives.) |
object |
Is the name of a data object or procedure. |
On W*32 only (see Conventions, Platform labels), 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: Lowercase |
L*X, M*X: Lowercase W*32: Lowercase |
L*X, M*X: Lowercase W*32: Uppercase |
L*X, M*X only: |
|||
Trailing underscore added |
No |
No |
Yes3 |
M*X only: |
|||
Leading underscore added |
No |
No |
Yes |
W*32 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 |
1C and STDCALL are synonyms on Linux systems. 2The Intel® Fortran calling convention 3On 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. 4W*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 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.
Mixed Language Programming: Adjusting Calling Conventions in Mixed-Language Programming Overview
Copyright © 1996-2011, Intel Corporation. All rights reserved.