The ATTRIBUTES directive lets you specify properties for data objects and procedures. It takes the following form: [See Note]
cDEC$ ATTRIBUTES att [,att]... :: object [,object]...
| ALIAS | REFERENCE |
| C | STDCALL |
| DLLEXPORT [1] | VALUE |
| DLLIMPORT [1] | VARYING |
| EXTERN | |
|
[1] WNT, W95 | |
The following table shows which properties can be used with various objects:
| Property | Variable and Array Declarations | Common Block Names [1] | Subprogram Specification and EXTERNAL Statements |
|---|---|---|---|
| ALIAS | No | Yes | Yes |
| C | No | Yes | Yes |
| DLLEXPORT | No | Yes | Yes |
| DLLIMPORT | No | Yes | Yes |
| EXTERN | Yes | No | No |
| REFERENCE | Yes | No | No |
| STDCALL | No | Yes | Yes |
| VALUE | Yes | No | No |
| VARYING | No | No | Yes |
|
[1] A common block name is specified as [/]common-block-name[/] | |||
These properties can be used in function and subroutine definitions,
in type declarations, and with the INTERFACE and ENTRY statements.
Properties applied to entities available through use or host
association are in effect during the association. For example,
consider the following:
In this case, the call to NEW_SUB within SUB2 uses the C and ALIAS
properties specified in the interface block.
The properties are described as follows:
Specifies an alternate external name to be used when referring to
external subprograms. Its form is:
The ALIAS property overrides the C (and STDCALL) property. If
both C and ALIAS are specified for a subprogram, the subprogram
is given the C calling convention, but not the C naming
convention. It instead receives the name given for ALIAS, with
no modifications.
ALIAS cannot be used with internal procedures, and it cannot be
applied to dummy arguments.
cDEC$ ATTRIBUTES ALIAS has the same effect as the cDEC$ ALIAS
directive (see Section 14.2.1.2).
Specify how data is to be passed when you use routines written in
C or assembler with FORTRAN or Fortran 90 routines.
On Intel processors, C and STDCALL have slightly different
meanings; on all other platforms, they are interpreted as
synonyms.
When applied to a subprogram, these properties define the
subprogram as having a specific set of calling conventions.
The following table summarizes the differences between the
calling conventions:
MODULE MOD1
INTERFACE
SUBROUTINE SUB1
!DEC$ ATTRIBUTES C, ALIAS:'othername' :: NEW_SUB
END SUBROUTINE
END INTERFACE
CONTAINS
SUBROUTINE SUB2
CALL NEW_SUB
END SUBROUTINE
END MODULE
ALIAS:external-name
| Convention | C [1] | STDCALL [1] | Default [2] |
|---|---|---|---|
| Arguments passed by value | Yes | Yes | No |
| Case of external subprogram names | VMS: Uppercase
U*X: Lowercase WNT: Lowercase W95: Lowercase |
VMS: Uppercase
U*X: Lowercase WNT: Lowercase W95: Lowercase |
VMS: Uppercase
U*X: Lowercase WNT: Uppercase W95: Uppercase |
| U*X only: | |||
| Trailing underscore added | No | No | Yes |
| WNT, W95: | |||
| Leading underscore added | Yes | Yes | Yes |
| Number of arguments added | No | Yes | Yes |
| Caller stack cleanup | Yes | No | No |
| Variable number of arguments | Yes | No | No |
|
[1] C and STDCALL are synonyms on OpenVMS and DIGITAL UNIX
systems, and Windows NT systems on Alpha processors
| |||
If C or STDCALL is specified for a subprogram, arguments (except
for arrays and characters) are passed by value. Subprograms using
standard Fortran 90 conventions pass arguments by reference.
On Intel processors, 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:
On all systems, the first character of the string is passed
(and padded with zeros out to INTEGER(4) length).
On all systems, the string is passed with no length.
See also the following description of REFERENCE.
Define a dynamic-link library's (DLL) interface for processes
that use them. The properties can be assigned to data objects or
procedures.
DLLEXPORT specifies that procedures or data are being exported to
other applications or DLLs. This causes the compiler to produce
efficient code, eliminating the need for a module definition
(.def) file to export symbols.
If a procedure (or data) is declared with the DLLEXPORT property,
it must be defined in the same module of the same program.
Symbols defined in a DLL are imported by programs that use them.
The program must link with the import DLL and use the DLLIMPORT
property inside the program unit that imports the symbol.
DLLIMPORT is specified in a declaration, not a definition, since
you cannot define a symbol you are importing.
Specifies that a variable is allocated in another source file.
EXTERN can be used in global variable declarations, but it must
not be applied to dummy arguments.
EXTERN must be used when accessing variables declared in other
languages.
Specify how a dummy argument is to be passed.
REFERENCE specifies a dummy argument's memory location is to be
passed instead of the argument's value.
VALUE specifies a dummy argument's value is to be passed instead
of the argument's memory location.
When a dummy argument has the VALUE property, the actual argument
passed to it can be of a different type. If necessary, type
conversion is performed before the subprogram is called.
When a complex (KIND=4 or KIND=8) argument is passed by value,
two floating-point arguments (one containing the real
part, the other containing the imaginary part) are passed by
immediate value.
Character values, substrings, assumed-size arrays, and adjustable
arrays cannot be passed by value.
If REFERENCE (only) is specified for a character argument, the
following occurs:
If REFERENCE and C (or STDCALL) are specified for a character
argument, the string is passed with no length.
VALUE is the default if the C or STDCALL property is specified in
the subprogram definition.
Allows a variable number of calling arguments. If VARYING is
specified, the C property must also be specified.
Either the first argument must be a number indicating how many
arguments to process, or the last argument must be a special
marker (such as -1) indicating it is the final argument. The
sequence of the arguments, and types and kinds must be compatible
with the called procedure.
Note: The following form is also allowed:
!MS$ATTRIBUTES att [,att]... :: object [,object]...