下面的代码对c_float接口和real接口的函数进行重载:
[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
program main
use iso_c_binding
implicit none
interface print_number
procedure:: print_number_real, print_number_c_float
end interface
call print_number(1.0)
contains
subroutine print_number_real(a)
real:: a
print*, a
end subroutine
subroutine print_number_c_float(a)
real(c_float):: a
print*, a
end subroutine
end program
提示错误:Error: Ambiguous interfaces in generic interface 'print_number' for 'print_number_real' at (1) and 'print_number_c_float' at (2)
难道是编译器把c_float和real当成同一种类型了吗?
|