I'm trying to dabble with the c++20 modules feature and would like to import the standard library headers as modules. Currently I have
import <iostream>;
int main()
{
std::cout << "hello world!" << std::endl;
return 0;
}
and I run the commands
g++-11 -fmodules-ts -std=c++20 -xc++-system-header iostream
g++-11 -fmodules-ts -std=c++20 -o program main.cpp
This gives a perfectly functioning hello world program and a module file at gcm.cache/usr/include/c++/11/iostream.gcm. But vscode complains:
"iostream" is not an importable header
My c_cpp_properties.json file is
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++-11",
"cStandard": "c17",
"intelliSenseMode": "linux-clang-x64",
"cppStandard": "c++20"
}
],
"version": 4
}
Possible solutions that I don't know how to implement:
- A way to tell vscode where this
iostream.gcmfile is - An alternative way of doing this where the
iostream.gcmobject ends up somewhere vscode already knows