Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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 a non-coindexed variable that has the TARGET attribute. It must have interoperable type and type parameters, and it must be a non-polymorphic variable with no length type parameters, or an assumed-type variable.

If it is an array, it must be contiguous with non-zero size. It cannot be a zero-length string. If it is a pointer, it must be associated. If it has the ALLOCATABLE attribute, it must be allocated.

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.