【发布时间】:2021-02-23 17:57:55
【问题描述】:
我正在 Visual Studio Code 中编写 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.
我应该如何在我的 Visual Studio Code 中进行配置,以便编译器可以使用 C++20 模块?
【问题讨论】:
-
我建议使用合适的构建系统,例如 CMake。 VScode 有一个 CMake 扩展,可以使用编辑器中的单个命令进行编译。
标签: c++ visual-studio-code vscode-settings c++20