C++调用C文件或者 C函数

来源:互联网 发布:wap网站源码 编辑:程序博客网 时间:2024/05/19 15:24

C++虽然说是和C有一定的兼容,但是在一些用法和混合编程时会出现冲突。
1. C++调用C的头文件最好使用以下方法:

#ifdef __cplusplus  extern "C" {  #endif #include "xxxxxx.h"#ifdef __cplusplus  }  #endif  

2.C++调用C的函数最好使用以下方法:

#ifdef __cplusplus  extern "C" {  #endif  void xxxxxxx(int AB);  void xxxxxx(char AABB);  #ifdef __cplusplus  }  #endif  
0 0
原创粉丝点击