我正在用Visual代码编写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."
}
]
}在我尝试使用syncstream之前,一切看起来都很好,这是在C++20中引入的。
当我运行#include <syncstream>时,编译器总是给出一个错误:
fatal error: syncstream: No such file or directory
5 | #include <syncstream>
| ^~~~~~~~~~~~
compilation terminated.如何在Visual代码中进行配置,以便编译器可以使用C++20模块?
发布于 2021-02-23 18:07:24
参见https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B20_library_features中的“同步缓冲的ostream”
您需要libstdc++11。您的编译器(g++10)还不支持syncstream。
https://stackoverflow.com/questions/66338566
复制相似问题