I am trying to compile some C++ code using VS Code and have some trouble with using different C++ version. I would like to compile it with an option -std=c++17 as some things I need to test out work in C++17 only (By default, Clang uses C++14).
So, I tried editing my tasks.json file to manually add an option to use C++17. However, even after doing that nothing seems to work.
Initially, I only edited the options part for g++ build active file but , as it didn't seem to work, I added that option to all tasks. Unfortunately, this didn't help either. Can you tell me where exactly I made a mistake there?
You can find tasks part of tasks,json file below.
"tasks": [
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-std=c++17"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-std=c++17"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
},
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-std=c++17"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
g++command outside of VS Code to confirm it can be compiled correctly on your machine?