我正在尝试使用c++20模块特性,并希望将标准库头作为模块导入。目前我有
import <iostream>;
int main()
{
std::cout << "hello world!" << std::endl;
return 0;
}我运行命令
g++-11 -fmodules-ts -std=c++20 -xc++-system-header iostream
g++-11 -fmodules-ts -std=c++20 -o program main.cpp这给出了一个功能完美的hello program和gcm.cache/usr/include/c++/11/iostream.gcm的一个模块文件。但是vscode抱怨道:
"iostream“不是一个重要的标题。
我的c_cpp_properties.json文件是
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++-11",
"cStandard": "c17",
"intelliSenseMode": "linux-clang-x64",
"cppStandard": "c++20"
}
],
"version": 4
}我不知道如何实现的可能解决方案:
iostream.gcm文件在哪里的一种方法iostream.gcm对象在vscode已知的某个地方结束时,另一种方法是这样做。发布于 2022-07-08 05:08:51
这是已知的IntelliSense 问题。
在导入C++20模块或C++源中的头单元时:
现状(截至2022年6月)
解决办法
#if __INTELLISENSE__
#include <iostream>
#else
import <iostream>;
#endifhttps://stackoverflow.com/questions/72905721
复制相似问题