Fortran中的结构

示例

该bind属性还可以应用于派生类型:

struct Goose {
   int flock;
   float buoyancy;
}

struct Goose goose_c;

鹅90

use, intrinsic :: iso_c_binding, only : c_int, c_float

type, bind(C) :: goose_t
  integer(c_int) :: flock
  real(c_float) :: buoyancy
end type goose_t

type(goose_t) :: goose_f

现在可以在goose_c和之间传输数据goose_f。Goose可以从Fortran中使用调用带有类型参数的C例程type(goose_t)。