如何解决如何在 VScode 中包含 C++20 模块
我正在用 VScode 编写 c++20。我的配置如下:
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac","includePath": [
"${workspaceFolder}/**"
],"defines": [],"macFrameworkPath": [
"/Library/Developer/CommandLinetools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],"compilerPath": "/usr/local/Cellar/gcc/10.2.0/bin/g++-10","cStandard": "c11","cppStandard": "c++20","intelliSenseMode": "clang-x64"
}
],"version": 4
}
tasks.json
:
{
"version": "2.0.0","tasks": [
{
"type": "cppbuild","label": "C/C++: clang++ build active file","command": "/usr/local/Cellar/gcc/10.2.0/bin/g++-10","args": [
"-g","-pthread","-std=c++20","-I/usr/local/Cellar/gcc/10.2.0/include","-I/usr/local/Cellar/fmt/7.1.3/include","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"
],"options": {
"cwd": "${workspaceFolder}"
},"problemmatcher": [
"$gcc"
],"group": {
"kind": "build","isDefault": true
},"detail": "Task generated by Debugger."
}
]
}
一切看起来都很好,直到我尝试使用 C++20 中引入的 syncstream
。
当我运行 #include <syncstream>
时,编译器总是给我错误:
Fatal error: syncstream: No such file or directory
5 | #include <syncstream>
| ^~~~~~~~~~~~
compilation terminated.
我想知道我应该如何在我的 vscode 中进行配置,以便编译器可以使用 C++20 模块?
解决方法
请参阅 https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_library_features 处的“同步缓冲 ostream”
你需要 libstdc++11。您的编译器 (g++10) 尚不支持 syncstream
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。