Why we use extern "C"

We often see the symbol extern "C"  in C++ source files.
Why use this?
Because C++ has overload function property like:
 
f(int i)      //defines f__Fi
f(int i ,char* j) //defines f__FiPc
 
When we link in other file
extern f(int);  // refers to f__FI
extern f(int,char*)  // refers to f__FiPc
 
But the C programming language's link symbol is not like this , because C don't have overload function.
 
int C:
f(int)  // defines _f
 
So, if we want use C lib , we must tell the compiler the link symbol is C style.
extern "C"{
   int f(int i);
}
by 1957
原文地址:https://www.cnblogs.com/x1957/p/2875663.html