Does extern "C" have any effect in C? Does extern "C" have any effect in C? c c

Does extern "C" have any effect in C?


No, it's not valid C. It should only be used in C++ code to refer to functions defined in C code. The extern "C" should be surrounded in a ifdef __cplusplus/#endif block:

// For one function#ifdef __cplusplusextern "C"#endifvoid func();// For more than one function#ifdef __cplusplusextern "C"{#endifvoid func1();void func2();#ifdef __cplusplus}#endif


this is a C++ notation to tell the compiler/linker to use C calling standards.

Usually that line is wrapped in an pre-processor statement.

#ifdef __cplusplusextern "C" {#endif// stuff#ifdef __cplusplus}#endif


Not valid in C. If present after preprocessing this will result in a diagnostic as per the standard.

For C++, this turns of name-mangling. See this for more details as to why it may be required. Can you post some more details?