test_cpp.cpp
------------------------------------------------------
#include <stdio.h>
// C++调用C函数的方法,将用到的函数全部重新声明一遍
extern "C"
{
extern int c_funcA();
}
// C调用C++函数的方法
extern "C" int cpp_funcA()
{
printf ("cpp_funcA\n");
return 0;
}
extern "C" int cpp_funcB()
{
printf ("cpp_funcB\n");
return 0;
}
int main()
{
c_funcA();
cpp_funcB();
return 0;
}
test_c.c
------------------------------------------------------
int cpp_funcA();
int c_funcA()
{
cpp_funcA();
return 0;
------------------------------------------------------
#include <stdio.h>
// C++调用C函数的方法,将用到的函数全部重新声明一遍
extern "C"
{
extern int c_funcA();
}
// C调用C++函数的方法
extern "C" int cpp_funcA()
{
printf ("cpp_funcA\n");
return 0;
}
extern "C" int cpp_funcB()
{
printf ("cpp_funcB\n");
return 0;
}
int main()
{
c_funcA();
cpp_funcB();
return 0;
}
test_c.c
------------------------------------------------------
int cpp_funcA();
int c_funcA()
{
cpp_funcA();
return 0;
}
C++是后来者,所以特殊处理都在CPP中做