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?
Figured out that there is a intrinsic type named constant c_null_ptr that can be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With