Clicky

Fortran Wiki
iso_c_binding

Description

iso_c_binding is a standard intrinsic module which defines named constants, types, and procedures for C interoperability.

Standard

Fortran 2003 and later

Intrinsic Procedures

The following intrinsic procedures are provided by the module; their definition can be found in the section Intrinsic Procedures of this manual.

Named Constants

The iso_c_binding module also provides the following named constants of type default integer, which can be used as kind type parameters.

Fortran TypeNamed constantC typeNote
integerc_intint
integerc_shortshort int
integerc_longlong int
integerc_long_longlong long int
integerc_signed_charsigned char/unsigned char
integerc_size_tsize_t
integerc_int8_tint8_t
integerc_int16_tint16_t
integerc_int32_tint32_t
integerc_int64_tint64_t
integerc_int_least8_tint_least8_t
integerc_int_least16_tint_least16_t
integerc_int_least32_tint_least32_t
integerc_int_least64_tint_least64_t
integerc_int_fast8_tint_fast8_t
integerc_int_fast16_tint_fast16_t
integerc_int_fast32_tint_fast32_t
integerc_int_fast64_tint_fast64_t
integerc_intmax_tintmax_t
integerc_intptr_tintptr_t
integerc_ptrdiff_tintptr_tTS 29113
realc_floatfloat
realc_doubledouble
realc_long_doublelong double
complexc_float_complexfloat _Complex
complexc_double_complexdouble _Complex
complexc_long_double_complexlong double _Complex
logicalc_bool_Bool
characterc_charchar

Additionally, the following parameters of type character(kind=c_char) are defined.

NameC definitionValue
c_null_charnull character'\0'
c_alertalert'\a'
c_backspacebackspace'\b'
c_form_feedform feed'\f'
c_new_linenew line'\'
c_carriage_returncarriage return'\r'
c_horizontal_tabhorizontal tab'\t'
c_vertical_tabvertical tab'\v'

Moreover, the following two named constants are defined:

NameType
c_null_ptrc_ptr
c_null_funptrc_funptr

Both are equivalent to the value NULL in C.