skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    Answer is in the comments, posting here for anyone with the same issue who finds this.

    Different compilers and language parsers implement C++ features at their own rate. Intellisense uses Edison Design Group (EDG) C++ frontend. It just so happens that this feature (mutli-dimensional braces operator) isn't supported yet by EDG, thus no matter what settings I changed it would give me an error. It IS supported by GCC, which is what CMake was using, hence the build working.

    I believe the only "solution" then is to wait until EDG supports this feature in a future update.

    For information about what features are supported by various language parsers and compilers, see this link: https://en.cppreference.com/w/cpp/compiler_support


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search