extern and extern “C” for variables
I'm writing a C++ shared library for a C program to use. However, I have a question about extern and extern "C" . Consider the following code My header file is like this: #ifdef __cplusplus extern "C" int global; extern "C" int addnumbers(int a, int b); #else extern int global; #endif This works perfectly fine; I just have to declare int global; in either my .cpp or my .c file. However, what I don't understand is: What is the difference between extern "C" and extern here? I tried commenting out extern "C" int global and it works! Why? I know that extern "C" is used for making C linkage. That's