インテル® Fortran コンパイラー 19.0 デベロッパー・ガイドおよびリファレンス

BIND

Statement and Attribute: Specifies that an object is interoperable with C and has external linkage.

The BIND attribute can be specified in a type declaration statement or a BIND statement, and takes one of the following forms:

Type Declaration Statement:

type, [att-ls, ] BIND (C [, NAME=ext-name]) [, att-ls] :: object

Statement:

BIND (C [, NAME=ext-name]) [::] object

type

Is a data type specifier.

att-ls

Is an optional list of attribute specifiers.

ext-name

Is a character scalar constant expression that can be used to construct the external name.

object

Is the name of a variable or common block. It can also be the name of an internal procedure if NAME= is not specified.

Description

If a common block is specified in a BIND statement, it must be specified with the same binding label in each scoping unit in which it is declared.

For variables and common blocks, BIND also implies the SAVE attribute, which may be explicitly confirmed with SAVE.

A variable given the BIND attribute (or declared in a BIND statement) must appear in the specification part of a module. You cannot specify BIND for a subroutine local variable or a variable in a main program.

The BIND attribute is similar to directive !DIR$ ATTRIBUTES C as follows:

However, procedure argument passing differs. When BIND is specified, procedure arguments are passed by reference unless the VALUE attribute is also specified.

The BIND attribute can optionally be used in a PROCEDURE, SUBROUTINE, or FUNCTION declaration. It must be used in an ENUM declaration.

Example

The following example shows the BIND attribute used in a type declaration statement, a statement, and a SUBROUTINE statement.

INTEGER, BIND(C) :: SOMEVAR 

BIND(C,NAME='SharedCommon') :: /SHAREDCOMMON/

! you need empty parens after the subroutine name if BIND is present
SUBROUTINE FOOBAR() BIND(C, NAME='FooBar')
...
END SUBROUTINE

See Also