ATTRIBUTES C and STDCALL

The ATTRIBUTES directive options C and STDCALL specify procedure calling, naming, and argument passing conventions. They take the following forms:

Syntax

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

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:

See Also