【发布时间】:2015-01-26 10:36:13
【问题描述】:
我有一个类型有两个指针,一个 Fortran 指针和一个 C 指针:
type mytype
procedure(whatever), pointer, nopass :: fortranPointer
type(c_ptr) :: cPointer
end type
我可以为两个指针分配一些东西,例如:
type(mytype) :: instance
instance%fortranPointer => fPtrToSomething
instance%cPointer = c_loc(somethingElse)
当我想初始化指针而不赋值时,我可以使用 null() 或 nullify 作为 Fortran 指针:
instance%fortranPointer => null()
但是如何将c_ptr 初始化为null? instance%cPointer = null() 不起作用,因为在分配的右侧不允许使用 null()。 c_loc(null()) 不允许,因为null() 不是变量,可以获取到哪个位置。
有类似c_null 的东西吗?
【问题讨论】:
标签: pointers null fortran fortran-iso-c-binding