一、C++调用C函数实例(关键是让C++调用的C接口按照C规范走即可)
注:可以先将C语言函数编译成静态库
// --------------cfun.h
#ifndef __C_FUN_H__
#define __C_FUN_H__
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
void cfun();
#ifdef __cplusplus
}
#endif
#endif
二、C调用C++函数实例(关键是让C调用的C++函数接口按照C规范走即可)
// --------------cppfun.h
#ifndef _CPP_FUN_H__
#define _CPP_FUN_H__
extern "C" void cppfun();
#endif