gfortran使用过程指针初始指向带有指针结果的函数

时间:2018-02-21 00:24:52

标签: fortran function-pointers gfortran

我正在尝试将模块中过程指针的初始目标设置为模块中的函数。当目标函数的结果是指针时,代码无法使用gfortran进行编译。请注意,它与英特尔编译器编译良好。我正在使用gfortran 6.4.0。

如果我从pointer的声明中删除the_proc属性,那么gfortran会毫无问题地编译它。

 module test_procedure_pointer
   implicit none
   private
   procedure(the_proc), pointer  :: ptr => the_proc
 contains    
   function the_proc()
     integer, pointer :: the_proc
   end function the_proc
 end module test_procedure_pointer

错误是:

% gfortran -c procpointer.f90  

procpointer.f90:4:50:

procedure(the_proc), pointer  :: ptr => the_proc  
                                   1  
**Error**: Pointer initialization target at (1) must have the TARGET attribute  

gfortran版本:

% gfortran --version  
GNU Fortran (GCC) 6.4.0  
Copyright (C) 2017 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions.  There is NO  
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

0 个答案:

没有答案