[英]Pass a different declared type to a binding procedure Fortran
给出以下代码
type t1
integer :: dum
type(aop), alloctable :: bc(:)
end type t1
type aop
procedure(A_INT), pass(t1), pointer :: ptr => null()
end type aop
abstract interface
subroutine A_INT ( this )
import t1
class(t1) , intent(in) :: this
end subroutine
end interface
有人可以解释为什么这是非法的吗? 至少编译器说
error #8170: The passed-object dummy argument is missing from the procedure interface. [A_INT]
procedure(A_INT), pass(t1),
-------------------^
更新
当我这样做时
type t1
integer :: dum
type(aop), alloctable :: bc(:)
end type t1
type aop
procedure(A_INT), pass(this), pointer :: ptr => null()
end type aop
abstract interface
subroutine A_INT ( this )
import t1
class(t1) , intent(in) :: this
end subroutine
end interface
我收到以下错误
error #8262: For a type-bound procedure that has the PASS binding attribute, the first dummy argument must have the same declared type as the type being defined. [THIS]
subroutine A_INT( this
我猜这意味着编译器期望第一个参数是aop
类型? 它是不可能有this
幸福的t1
类型?
您正在使用pass(t1)
BU没有伪参数t1
,只存在争论this
是类型t1
。
对于单个伪参数,我通常根本不会在此处使用任何显式pass
。 传递的伪参数只有在与定义指针的类型相同的类型时才有意义。 否则,对于其他类型的参数, 只需使用nopass
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.