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:

Syntax

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 initialization expression that can be used to construct the external name.


object
Is the name of a variable, common block, or procedure.

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 !DEC$ 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 be used in a SUBROUTINE or FUNCTION declaration.

See Also

Modules and Module Procedures, Type Declarations, Compatible attributes, Pointer Assignments, FUNCTION, SUBROUTINE

Examples

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/
INTERFACE
  SUBROUTINE FOOBAR, BIND(C, NAME="FooBar")
  END SUBROUTINE