pointers - 过程指针,派生类型

标签 pointers fortran function-pointers

以下内容无法在 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

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

最佳答案

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

procedure(interface1), pointer, nopass :: p

编辑:针对您的评论,如果您想使用 pass 关键字,则必须将界面更改为:

抽象接口(interface)
整数函数 interface1(passed_object, a)
进口::type1
类(type1),意图(...)::passed_object
真实的,意图(in)::a
END函数接口(interface)1
结束接口(interface)

关于pointers - 过程指针,派生类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5502592/

相关文章:

c++ - 尝试分配函数指针时获取 "Void value not ignored as it ought to be"

c++ - Position 2D array bug as parameter 导致内存转储

Fortran 无格式输出,每个 MPI 进程写入数组的一部分

c - 在c中写一个函数指针

C : Printing a pointer to an array seems to print a junk value also

C 指针和调用方法?

algorithm - 如何在DLL中存储大量只读数据?

fortran - Fortran 中的用户定义运算符

c++ - "does not name a type"尝试使用指向函数的指针时出错

c - 如何在 C 中实现 "private/restricted"函数?