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.
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"
}
Note that if you're copying the above tasks.json
directly, you'll need to have a folder named out
in your workspace root.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…