5份文件:a.c和a.h和b.cpp和b.h和main.c
其中main.c调用b.cpp,b.cpp调用a.c
main.c
#include "./b.h"
int main(void)
{
int t=funC();
while (1)
{
}
}
b.h
#ifndef _B_
#define _B_
#ifdef __cplusplus
extern "C" {
#endif
int funC(void);
#ifdef __cplusplus
}
#endif
#endif
b.cpp
#include "./b.h"
#include "./a.h"
class B{
public:
int funB(void);
};
int B::funB(void){
return funA();
}
#ifdef __cplusplus
extern "C" {
#endif
int funC(void){
B* b=new B();
return b->funB();
}
#ifdef __cplusplus
}
#endif
a.h
#ifndef _A_
#define _A_
#ifdef __cplusplus
extern "C" {
#endif
int funA(void);
#ifdef __cplusplus
}
#endif
#endif
a.c
#include "./a.h"
int funA(){
return 2;
}
参考:https://blog.csdn.net/weixin_30241919/article/details/99173820
标签:__,int,cplusplus,ifdef,C++,嵌入式,endif,keil5,void From: https://www.cnblogs.com/LPworld/p/17529678.html