ATTRIBUTES

General Compiler Directive: Declares properties for specified variables.

Syntax

cDEC$ ATTRIBUTES att [, att] ... :: object [, object] ...

c
Is one of the following: C (or c), !, or *. (See Syntax Rules for Compiler Directives.)


att
Is one of the following options (or properties):


ALIAS DEFAULT NO_ARG_CHECK
ALIGN DLLEXPORT NOINLINE
ALLOCATABLE DLLIMPORT NOMIXED_STR_LEN_ARG
ALLOW_NULL EXTERN REFERENCE
ARRAY_VISUALIZER FORCEINLINE STDCALL
C IGNORE_LOC VALUE
DECORATE INLINE VARYING

object
Is the name of a data object or procedure.

The following table shows which ATTRIBUTES options can be used with various objects:

Option Variable
and Array Declarations
Common Block Names1 Subprogram Specification and
EXTERNAL Statements
ALIAS No Yes Yes
ALIGN Yes No No
ALLOCATABLE Yes2 No No
ALLOW_NULL Yes No No
ARRAY_VISUALIZER Yes2 No No
C No Yes Yes
DECORATE No No Yes
DEFAULT No Yes Yes
DLLEXPORT Yes3 Yes Yes
DLLIMPORT Yes Yes Yes
EXTERN Yes No No
FORCEINLINE No No Yes
IGNORE_LOC Yes4 No No
INLINE No No Yes
NO_ARG_CHECK Yes No Yes5
NOINLINE No No Yes
NOMIXED_STR_LEN_ARG No No Yes
REFERENCE Yes No Yes
STDCALL No Yes Yes
VALUE Yes No No
VARYING No No Yes
1 A common block name is specified as [/]common-block-name[/]
2 This option can only be applied to arrays.
3 Module-level variables and arrays only.
4 This option can only be applied to INTERFACE blocks.
5 This option cannot be applied to EXTERNAL statements.

These options can be used in function and subroutine definitions, in type declarations, and with the INTERFACE and ENTRY statements.

Options applied to entities available through use or host association are in effect during the association. For example, consider the following:

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

In this case, the call to NEW_SUB within SUB2 uses the C and ALIAS options specified in the interface block.

The following are ATTRIBUTES options:

Options C, STDCALL, REFERENCE, VALUE, and VARYING affect the calling conventions of routines:

See Also

Building Applications: Programming with Mixed Languages Overview, General Compiler Directives

Examples

INTERFACE
   SUBROUTINE For_Sub (I)
     !DEC$ ATTRIBUTES C, ALIAS:'_For_Sub' :: For_Sub
     INTEGER I
   END SUBROUTINE For_Sub
END INTERFACE

You can assign more than one option to multiple variables with the same compiler directive. All assigned options apply to all specified variables. For example:

 !DEC$ ATTRIBUTES REFERENCE, VARYING, C :: A, B, C 

In this case, the variables A, B, and C are assigned the REFERENCE, VARYING, and C options. The only restriction on the number of options and variables is that the entire compiler directive must fit on one line.

The identifier of the variable or procedure that is assigned one or more options must be a simple name. It cannot include initialization or array dimensions. For example, the following is not allowed:

 !DEC$ ATTRIBUTES C :: A(10)  ! This is illegal.  

The following shows another example:

SUBROUTINE ARRAYTEST(arr)
!DEC$ ATTRIBUTES DLLEXPORT :: ARRAYTEST
   REAL(4) arr(3, 7)
   INTEGER i, j
   DO i = 1, 3
     DO j = 1, 7
       arr (i, j) = 11.0 * i + j
     END DO
   END DO
END SUBROUTINE