ATTRIBUTES C and STDCALL

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.

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, ATTRIBUTES STDCALL and ATTRIBUTES C have no effect. 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.

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

Linux: Lowercase

Windows: Lowercase

Linux: Lowercase

Windows: Lowercase

Linux: Lowercase

Windows: Uppercase

Linux only:

Trailing underscore added

No

No

Yes3

Windows only:

Leading underscore added

Yes

Yes

No

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*, 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.

If C or STDCALL is specified for a subprogram, arguments (except for arrays, large derived types, and characters) are passed by value. Subprograms using standard Fortran conventions pass arguments by reference.

Character arguments are passed as follows:

See Also