c++和c混合编程
- 第一步:在C头文件的最顶端加上如下代码(__cplusplus只存在于C++编译器下)
#ifdef __cplusplus
extern "C" {
#endif
- 第二步:在C头文件的最尾部加入如下代码
#ifdef __cplusplus
}
#endif
本文介绍了如何在C++环境中进行C语言代码的混合编程,通过在C头文件中添加特定的条件编译指令,确保代码在C++编译器下正确工作。
c++和c混合编程
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
被折叠的 条评论
为什么被折叠?