Reputation: 11760
I have a type with two pointers, one Fortran pointer and one C pointer:
type mytype
procedure(whatever), pointer, nopass :: fortranPointer
type(c_ptr) :: cPointer
end type
I can assign something to both pointers like:
type(mytype) :: instance
instance%fortranPointer => fPtrToSomething
instance%cPointer = c_loc(somethingElse)
When I want to initialize the pointers without assigning something, I can use null()
or nullify
for the Fortran pointer:
instance%fortranPointer => null()
But how can I initialize the c_ptr
to null? instance%cPointer = null()
is not working as null()
is not allowed on the right hand side of an assignement. c_loc(null())
is not allowed as null()
is not a variable, which location can be obtained.
Is there something like a c_null
?
Upvotes: 3
Views: 2182
Reputation: 11760
Figured out that there is a intrinsic type named constant c_null_ptr
that can be used.
Upvotes: 3