Compiler error for conflicting variable declarations: “conflicts with new declaration with 'C' linkage”
问题 I ran across some legacy code that's failing to build on a newer compiler. The boiled down example: int x; extern "C" { int x }; // conflicts with C++ linkage above // note: without the braces it would've been equivalent to: // extern "C" { extern int x; } // // for reference, see the notes section here: // http://en.cppreference.com/w/cpp/language/language_linkage#notes The older compilers weren't flagging it, but both gcc (as of 4.1.2) and clang flag it. Clang's output: error: declaration