1、新建的C++文件名为xx.cpp和xx.h。
2、以前的C文件xx2.c可以右击文件,属性改为C++ Source file。在xx2.h中修改为
#ifndef _XX_H_
#define _XX_H_
#ifdef __cplusplus
extern "C" {
#endif
......
#ifdef __cplusplus
}
#endif
#endif
3、再有C文件需要调用xx2.c文件中的程序时直接添加xx2.h头文件,调用函数即可,无需修改文件属性。
1、新建的C++文件名为xx.cpp和xx.h。
2、以前的C文件xx2.c可以右击文件,属性改为C++ Source file。在xx2.h中修改为
#ifndef _XX_H_
#define _XX_H_
#ifdef __cplusplus
extern "C" {
#endif
......
#ifdef __cplusplus
}
#endif
#endif
3、再有C文件需要调用xx2.c文件中的程序时直接添加xx2.h头文件,调用函数即可,无需修改文件属性。