---
title: Fortran和C/C++混合编程
description: "为了保证链接成功，需要在C代码中为混合编程中进行交换信息的全局变量和函数名后缀“_”或者使用编译选项-fno-underscoring，否则会出现链接报错。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenggrf/codeprtr/kunpengtaishanporting_12_0111.html
sourcePath: /source/zh/kunpenggrf/codeprtr/kunpengtaishanporting_12_0111.html
indexId: c6c579636f4a76aab6219f0a07c511e3ae8852a3d6528bfc9ee7a0b85fd4856d65
---
# 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) {
//实现
}
```
