When compiling c++-20 modules with clang. I get strange compilation errors when importing a file that imports another file that imports a third file like so:
// a.cppm
#include <string>
export module a;
export std::string getStuffA() {
return "a";
}
// b.cppm
#include <string>
import a;
export module b;
export std::string getStuffB() {
return "b" + getStuffA();
}
// c.cpp
#include <string>
import b;
int main() {
std::cout << getStuffB() << std::endl;
return 0;
}
The compiler outputs:
In file included from ./src/c.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/ostream:38:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/ios:44:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_ios.h:37:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/locale_facets.h:2569:5: error: inline declaration of 'isspace' follows non-inline definition
And it lists some more functions that seems to have both inline and non-inline definiton, like isprint, iscntrl, isupper.
Is there any way to get around these errors.
Note: Removing std::string
and #include <string>
removes the compilation errors, so I think that the errors comes from <string>