Intel® Fortran Compiler 16.0 User and Reference Guide

C_LOC

Intrinsic Module Inquiry function (Generic): Returns the C address of an argument.

Module

USE, INTRINSIC :: ISO_C_BINDING

Syntax

result = C_LOC(x)

x

(Input) Is one of the following:

  • An interoperable variable that has the TARGET attribute; if the variable is an array, it does not have to be interoperable

  • An interoperable, allocatable, variable that is allocated, has the TARGET attribute, and is not an array of size zero; if the variable is an array, it does not have to be interoperable

  • An associated, interoperable scalar pointer

  • A scalar that has no length type parameters and is one of the following:

    • A nonallocatable, nonpointer variable that has the TARGET attribute

    • An allocatable variable that is allocated and has the TARGET attribute

    • An associated pointer

Results

The result is a scalar of derived type C_PTR. The result value represents the C address of the argument.

The result is a value that can be used as an actual CPTR argument in a call to procedure C_F_POINTER where fptr has attributes that allow the pointer assignment fptr=>x. Such a call to C_F_POINTER has the effect of the pointer assignment fptr=>x.

If x is a scalar, the result is determined as if C_PTR were a derived type containing a scalar pointer component PX of the type and type parameters of x and the pointer assignment CPTR%PX=>x were executed.

If x is an array, the result is determined as if C_PTR were a derived type containing a scalar pointer component PX of the type and type parameters of x and the pointer assignment CPTR%PX to the first element of x were executed.

See Also