2011-03-31 56 views
6

以下犯规编译英特尔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 

错误:

error #8262: The passed-object dummy argument must be dummy data object with the same declared type as the type being defined. 

回答

8

nopass属性添加到过程指针组件的声明。

procedure(interface1), pointer, nopass :: p 

编辑:在回答你的评论,如果你想使用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 
+0

谢谢!你介意解释,为什么这解决了我的问题? – 2011-03-31 18:12:05

+0

没有明确指定'n​​opass'属性,组件自动具有'pass'属性(也可以明确指定)。这意味着过程的第一个伪参数应该与被定义的类型具有相同的类型(如错误消息中所述)。当引用procpointer组件时,通过它调用的对象会自动作为第一个参数传递。 – eriktous 2011-03-31 18:21:13

+0

如果我想使用'pass'关键字,我将如何更改'interface1'? – 2011-05-04 10:46:13