c++visual-studio-codecmakeintellisensec++23

VS Code cpptools 1.20 does not support C++23 multidimensional subscript operator in IntelliSense. Why?


My program builds correctly according to the C++ standard I have set in my CMakeLists.txt file, but Intellisense flags newer features as errors even though I've told it to defer to CMake for the config info.

I'm using CMake and CMake-tools extensions in VSCode, editing a C++ project. In my root-folder CMakeLists.txt, I have set(CMAKE_CXX_STANDARD 23).

In one of my header files, I use the following C++23 feature (multiple arguments in braces operator):

  Port *operator[](const string name, const size_t index) { /* .. code .. */ }

As expected, I can build and run this program fine. But Intellisense always marks that line as an error, saying there's too many arguments: too many parameters for this operator function C/C++(344)

My c_cpp_properties.json file has the following contents:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "intelliSenseMode": "linux-gcc-arm64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

I've also tried adding "cppStandard": "c++23", with no difference.

Env info

I'm running on linux on a raspberry pi. The Pi is running headless and I'm using the SSH VS code extension to edit from a different computer. I doubt that impacts it though, because I believe the C/C++ extension runs on the pi, and I see the exact same thing whether I'm remoting in from a windows or linux machine.


Solution

  • The Cpptools extension's support for C++23's new multidimensional subscript operator language feature in IntelliSense (not in build, which is handled by whichever compiler you use for build) is (somewhat-unofficially) tracked by issue ticket Support multidimensional array subscript operator with windows-clang-x64 #11400. Quoting Colen's reply in that issue ticket:

    The C/C++ Extension leverages the EDG compiler front-end and is equivalent to the EDG eccp column in this table: https://en.cppreference.com/w/cpp/compiler_support/23

    We'll keep this issue open for tracking, but expect this feature to start working as expected once EDG has added support for it.