Search code examples
c++cinterfacemixing

c and c++ mixed


I need to call cpp method from c file. I have written this interface for that..

cpp file

extern "C" void C_Test(int p){
      Class::CPP_Test(p);
}

c file

extern void C_Test(int p);


void C_Function(){
   C_Test(10); //error
}

I get error in c file "undefined reference to C_Test(int)"

any idea whats wrong?


Solution

  • I am using C++ compiler for both types of files. Without "C" it works!! Also without extern "c" it works!