What is the Effect of Declaring 'extern "C"' in the Header to a C++ Shared Library?
- by Adam
Based on this question I understand the purpose of the construct in linking C libraries with C++ code. Now suppose the following:
I have a '.so' shared library compiled with a C++ compiler. The header has a 'typedef stuct' and a number of function declarations. If the header includes the extern "C" declaration...
#ifdef __cplusplus
extern "C"
{
#endif
// typedef struct ...;
// function decls
#ifdef __cplusplus
}
#endif
... what is the effect? Specifically I'm wondering if there are any detrimental side effects of that declaration since the shared library is compiled as C++, not C.
Is there any reason to have the extern "C" declaration in this case?