本文介绍了过程指针,派生类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下不在Intel Fortran XE 2011中编译:

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

抽象接口
整数函数interface1(a)
实数,意图(in):: a
END函数interface1
END INTERFACE

错误:

 错误#8262:传递对象伪参数必须是与定义的类型具有相同声明类型的虚拟数据对象。 


解决方案

添加 nopass
$ p $ procedure(interface1),pointer,nopass :: p(code $ c>)指向过程指针组件的声明。

编辑:为了回应您的评论,如果您想使用pass关键字,如下所示:

 
ABSTRACT INTERFACE
整数函数interface1(passed_object,a)
import :: type1
class(type1),intent(...):: passed_object
real,intent(in):: a
END函数interface1
END INTERFACE

 

The following doesnt compile in Intel 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

The error:

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

Add the nopass attribute to the declaration of the procedure pointer component.

procedure(interface1), pointer, nopass :: p

Edit: In response to your comment, if you want to use the pass keyword, the interface would have to be changed as such:

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

这篇关于过程指针,派生类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:09