[Fortran] 纯文本查看 复制代码 module interfaces
interface
integer function sum(a,n) Bind( C , Name = "sum" )
use ,Intrinsic::ISO_C_Binding
type(C_PTR) , value :: a
integer , value :: n
end function sum
end interface
end module interfaces
program main
use interfaces
use , intrinsic :: ISO_C_Binding
implicit none
integer , target :: x(5) = [1,2,3,4,5]
write(*,*) "Sum=" , sum( c_loc(x) , size(x) )
end program main
[C] 纯文本查看 复制代码 int sum(int a[], int n)
{
int i,s=0;
for(i=0;i<n;i++)
s+=a[i];
return s;
}
|