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 General Directives.)


att
Is one of the following:


ADDRESS641 DESCRIPTOR322 REFERENCE
ALIAS DESCRIPTOR642 REFERENCE322
ALLOW_NULL DLLEXPORT REFERENCE642
ARRAY_VISUALIZER DLLIMPORT STDCALL
C EXTERN VALUE
DECORATE IGNORE_LOC VARYING
DEFAULT NO_ARG_CHECK  
DESCRIPTOR2 NOMIXED_STR_LEN_ARG  
1 VMS, WNT
2 VMS only

object
Is the name of a data object or procedure.

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
ADDRESS64 Yes Yes No
ALIAS No Yes Yes
ALLOW_NULL Yes No No
ARRAY_VISUALIZER2 Yes No No
C No Yes Yes
DECORATE No No Yes
DEFAULT No Yes Yes
DESCRIPTOR Yes3 No No
DESCRIPTOR32 Yes3 No No
DESCRIPTOR64 Yes3 No No
DLLEXPORT Yes4 Yes Yes
DLLIMPORT Yes Yes Yes
EXTERN Yes No No
IGNORE_LOC Yes3 No No
NO_ARG_CHECK Yes No Yes5
NOMIXED_STR_LEN_ARG No No Yes
REFERENCE Yes No Yes
REFERENCE32 Yes No No
REFERENCE64 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[/]
2 This property can only be applied to arrays.
3 This property can only be applied to INTERFACE blocks.
4 Module-level variables and arrays only.
5 This property cannot be applied to EXTERNAL statements.

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:

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 properties specified in the interface block.

The properties are described as follows:

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

The following form is also allowed for this attribute: !MS$ATTRIBUTES att [,att] ... :: object [,object] ...

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: Programming with Mixed Languages, Creating Fortran DLLs, 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 property to multiple variables with the same compiler directive. All properties apply to all the 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 properties. The only restriction on the number of properties and variables is that the entire compiler directive must fit on one line.

The identifier of the variable or procedure assigned properties 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