VSCode C/C++ extension not recognizing -std=c++2c features

2 hours ago 4
ARTICLE AD BOX

I use GCC15 and -std=c++2c. From my observation, I should use -std=c++2c instead of -std=c++26 in order to use std::views::concat. Now I'm using VSCode and the extensions "C/C++" and "CMake".

This is my code main.cpp:

#include <ranges> #include <vector> #include <iostream> int main() { std::vector v1{1, 2, 3}; std::vector v2{4, 5, 6}; for (auto x : std::views::concat(v1, v2)) std::cout << x << ' '; return 0; }

This is the CMakeLists.txt:

cmake_minimum_required(VERSION 3.20) project(cpp26test) set(CMAKE_CXX_COMPILER "g++-15") set(CMAKE_CXX_FLAGS "-std=c++2c") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_executable(cpp26test main.cpp)

Compiling it directly with g++-15 main.cpp -o main -std=c++2c generates correct output. However, in VSCode there is always a red squiggle under "concat" saying that "namespace std::ranges::views has no member 'concat'".

.vscode/c_cpp_properties.json:

{ "configurations": [ { "name": "Linux", "intelliSenseMode": "linux-gcc-x64", "compilerPath": "/usr/bin/g++-15", "compilerArgs": [ "-std=c++2c" ] } ], "version": 4 }

Here I cannot write "cppStandard": "c++2c" as this value is not recognized and the red squiggle on "concat" remains.

Same problem arises if I use CMake, with the following CMakeLists.txt and c_cpp_properties.json:

cmake_minimum_required(VERSION 3.28) project(cpp26test) set(CMAKE_CXX_COMPILER "g++-15") set(CMAKE_CXX_FLAGS "-std=c++2c") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_executable(cpp26test main.cpp) { "configurations": [ { "name": "CMake", "configurationProvider": "ms-vscode.cmake-tools", "compileCommands": "${workspaceFolder}/build/compile_commands.json" } ], "version": 4 }

VSCode version: 1.110.0

C/C++ extension version: 1.30.5

GCC version: 15.2.0

System: Ubuntu 24.04

Read Entire Article