How to enable C++17 support in VSCode C++ Extension(如何在 VSCode C++ 扩展中启用 C++17 支持)
问题描述
我一直在 std::string_view 上出现错误曲线,但我能够构建得很好.有没有办法告诉智能感知或 C++ linter 使用 C++17?
I keep on getting error squiggles on std::string_view, but I am able to build just fine. Is there a way to tell intellisense or the C++ linter to use C++17?
我得到的具体错误是:
namespace "std" has no member "string_view"
推荐答案
现在这变得容易多了.在您的 vs code 扩展设置中搜索 cppstandard
,然后从下拉列表中选择您希望扩展使用的 C++ 版本.
This has become much easier now. Search for cppstandard
in your vs code extension settings and choose the version of C++ you want the extension to use from the drop down.
为了确保您的调试器使用相同的版本,请确保您的 tasks.json
具有类似的内容,其中重要的几行是 --std
和之后的行定义版本.
In order to make sure your debugger is using the same version, make sure you have something like this for your tasks.json
, where the important lines are the --std
and the line after that defines the version.
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"--std",
"c++17",
"-I",
"${fileDirname}",
"-g",
"${fileDirname}/*.cpp",
"-o",
"${workspaceFolder}/out/${fileBasenameNoExtension}.o"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
请注意,如果您直接复制上述 tasks.json
,则您的工作区根目录中需要有一个名为 out
的文件夹.
Note that if you're copying the above tasks.json
directly, you'll need to have a folder named out
in your workspace root.
这篇关于如何在 VSCode C++ 扩展中启用 C++17 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 VSCode C++ 扩展中启用 C++17 支持
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- C++ 协变模板 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 如何对自定义类的向量使用std::find()? 2022-11-07
- Stroustrup 的 Simple_window.h 2022-01-01