过程指针,派生类型

Joh*_*rer 6 fortran pointers function-pointers

以下不在英特尔Fortran XE 2011中编译:

TYPE type1
    procedure(interface1),POINTER::p
END TYPE type1

ABSTRACT INTERFACE 
    integer function interface1(a)
        real,intent(in)::a    
    END function interface1
END INTERFACE
Run Code Online (Sandbox Code Playgroud)

错误:

error #8262: The passed-object dummy argument must be dummy data object with the same declared type as the type being defined.
Run Code Online (Sandbox Code Playgroud)

eri*_*ous 8

将该nopass属性添加到过程指针组件的声明中.

procedure(interface1), pointer, nopass :: p
Run Code Online (Sandbox Code Playgroud)

编辑:在回复您的评论时,如果您想使用pass关键字,则必须更改界面:

ABSTRACT INTERFACE 
    integer function interface1(passed_object, a)
        import :: type1
        class(type1), intent(...) :: passed_object
        real,         intent(in)  :: a
    END function interface1
END INTERFACE