The basic example given in How do I use C++ modules in Clang? works for me but doesn't import the standard library (eg via import std.stdio;
); after going over http://clang.llvm.org/docs/Modules.html it wasn't clear how to use the standard library in a C++ module, eg:
// foo.cppm:
export module foo;
// works: #include <stdio.h>
// none of these work:
import std.stdio;
import std.io;
import std;
export void test_foo(){
printf("hello world\n");
}
this gives an error:
clang++ -std=c++17 -fmodules-ts --precompile foo.cppm -o foo.pcm
foo.cppm:4:8: fatal error: module 'std.stdio' not found
NOTE:
clang++ --version
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.4.0
I'm on OSX.
I also tried clang from brew install llvm and also didn't work.
What's the simplest way to make something like this work?