Import of C++ module appears within extern "C" language linkage specification

Clang (and Swift by extension) typically allow you to use extern "C" specifiers in C++ headers when you need to mix C and C++. However, certain #include directives inside of extern "C" blocks might be prohibited, like in your case. This is intentional, as in that case an #include doesn't textually include the referenced header file, but rather it loads up a module that was already parsed using the C++ language mode for the referenced header.

The code for the C dependency that's breaking you should be fixed. All the #include directives used by the headers should be moved outside of the extern "C" block. It might also be necessary to "sink" the extern "C" specifier into the sources of the included headers themselves instead. That should resolve the issue.

1 Like