# ATTRIBUTES REFERENCE and VALUE

The ATTRIBUTES directive options REFERENCE and VALUE specify how a dummy argument is to be passed.

!DIR$ ATTRIBUTES REFERENCE :: arg

!DIR$ ATTRIBUTES VALUE :: arg

arg | Is the name of a dummy argument.

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 VALUE is specified for a dummy argument, 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 string is passed with no length.

If REFERENCE is specified for a character argument, and C (or STDCALL) has been specified for the routine, the string is passed with no length. This is true even if REFERENCE is also specified for the routine.

If REFERENCE and C (or STDCALL) are specified for a routine, but REFERENCE has not been specified for the argument, the string is passed with the length.

VALUE is the default if the C or STDCALL option is specified in the subprogram definition.

In the following example integer x is passed by value:

          SUBROUTINE Subr (x)
          INTEGER x
    !DIR$ ATTRIBUTES VALUE :: x

## See Also

C and STDCALL
ATTRIBUTES
Syntax Rules for Compiler Directives

Mixed Language Programming: Adjusting Calling Conventions in Mixed-Language Programming Overview