Fortran和C/C++混合编程
为了保证链接成功,需要在C代码中对在混合编程中进行交换信息的全局变量和函数名后缀“_”或者使用编译选项-fno-underscoring,否则会出现链接报错。
代码实例:
Fortran主程序:
program test
external ctest
ii=20
x=200.0
call ctest(ii,x) //调用C函数接口
end
C代码:
void ctest_(int *ii,float *x) {
//实现
}
父主题: Fortran常见迁移问题(语法差异)