I am a beginner, using VSCode on macOS. Trying to iterate using square brackets which is requires C++17:
for (auto [document_id, relevance] : documents) {
cout << "{ document_id = "s << document_id << ", relevance = "s << relevance << " }"s
<< endl;
}
When trying to Terminal -> Run build task, -std=gnu++14 flag appears before all other flags, even if -std=gnu++17 specified in tasks.json
Here are my tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++",
"command": "/usr/bin/clang++",
"args": [
"-std=gnu++17",
"-stdlib=libc++",
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "/usr/bin/clang++"
}
]
}
Here is the output:
* Executing task: C/C++: clang++
Starting build...
/usr/bin/clang++ -std=gnu++14 -std=gnu++17 -stdlib=libc++ -fcolor-diagnostics -fansi-escape-codes -g /Users/user/Documents/С++/000test/main.cpp -o /Users/user/Documents/С++/000test/main
Build finished successfully.
* Terminal will be reused by tasks, press any key to close it.
What could be the problem?
I also tried to change the C++ version to 17 in the C/C++ extension, but to no avail.
When running with "-std=gnu++17", "-stdlib=libc++"
in tasks json no warning appears, but does the second -std flag override the first one?
I also found this topic, but I dont even have CMake extension in vscode.
/usr/bin/clang++
in the terminal looks like an alias for/usr/bin/clang++ -std=gnu++14
. – Outrageous