How to Set the C++ Language Standard Version in VS Code

Manually editing the tasks.json to add the desired C++ compiler option.

So, after the previous discussion on that confusing UI design choice, how can you set the C++ language standard version for building your C++ code in VS Code with the MS C/C++ Extension?

One option is to open the tasks.json file, and edit it to add the desired compiler option. In particular, to enable C++20 compilation mode, the option for the MSVC compiler is /std:c++20. So, add this option as a string “/std:c++20” in the args property array in tasks.json:

Specifying the C++ language standard version in tasks.json as a command line option.
Editing the tasks.json file to specify the C++ language standard version in the “args” array

I still think that this modification to tasks.json should have been automatically done by the C/C++ Configurations UI, once the C++20 language standard version is set in there.

Leave a comment