The most common solution is to write the C interface to your C ++ functions. This is C ++ code that is declared using extern "C" { ... } . These wrapper functions can call any C ++ code that they like, but since they are declared extern "C" , they will not be manipulated with names (you cannot create namespaces or overload here).
This should be related to your C file, and you're good to go.
That is, the header file contains
#ifdef __cplusplus extern "C" { #endif void wrapper1(void); int wrapper2(int x); char* wrapper3(int y); #ifdef __cplusplus } #endif
Ifdefs are needed to protect the C compiler from extern "C" . And you implement them in your C ++ source
void wrapper1(void) { Util::funcOne(); } int wrapper2(int x) { return Util::funcTwo(x); } char* wrapper3(int y) { return Util::funcThree(y); }
falstro
source share