2011-03-31 54 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