I'm running VS Code on freshly installed Ubuntu 22.04 LTS. Whatever I try, my language standard is stuck at c 17. I use gcc compiler. To check the issue I run the following code:
#include <iostream>
int main()
{
if (__cplusplus == 201703L) std::cout << "C 17\n";
return 0;
}
Output is always the same: C 17
- I've set
"cppStandard": "c 23",
in c_cpp_proporties.json. - I've set C standard in C/C Configurations settings to c 23.
- I've set compiler arguments to
-std=c 23
.
I've been resetting VS Code, creating new files, reinstalling extensions, nothing. Snippet from my tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C : g build active file",
"command": "/usr/bin/g ",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Installed extensions:
- C/C by Microsoft
- C/C Extension Pack by Microsoft
- C/C Themes by Microsoft
- CMake Tools by Microsoft
- Better C Syntax by Jeff Hykin
CodePudding user response:
As many of the commentators pointed out, tasks.json
is used for compiling. @Some programmer dude correctly explained that I should put argument inside it. Updating task.json
with the following code is the solution:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C : g build active file",
"command": "/usr/bin/g ",
"args": [
"-std=c 23",
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}