[Fortran-experiments] Bind(c) first experiences
Brooks Moses
brooks.moses@codesourcery.com
Wed Dec 20 14:57:00 GMT 2006
Tobias Burnus wrote:
> Thirdly,
> type(c_funptr), pointer :: pnter
> is accepted, whereas NAG f95 gives me an error:
> Error: test.f90, line 4: BIND(C) variable PNTER is a POINTER
> (I think NAG's error message is a bit misleading.)
>
> I think this is prohibited; see F2003, 15.2.2 / 15.2.3:
> "C_PTR and C_FUNPTR shall be derived types with private components."
> "C1505 (R429) Each component of a derived type with the BIND attribute
> shall be a nonpointer, nonallocatable data component with interoperable
> type and type parameters."
But C1505 is referring to components of the derived type (that is, to
the parts that make up the type), not to variables of the type, whereas
this is a variable of the derived type. Thus, that restriction doesn't
apply.
What C1505 is prohibiting is, instead, things like this declaration of "cp":
type foo
integer, pointer :: p
end type
type(foo), bind(c) :: cp
I'm not sure if there's some other rule that prohibits declaring
pointers as bind(c) variables, and unfortunately I should probably be
off to bed now rather than looking it up.
- Brooks
More information about the Fortran
mailing list