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 支持
基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
