0

I am currently working with an open source c++ project and have a weird intelliSense error. I have the following two *.cpp files in the same folder, and as can be seen in the image. the intellisense works in one file but not in the other.

enter image description here

c_cpp_properties.json is as follows:

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}/src/**",
            "${workspaceFolder}/utils/**",
            "C:/libs/install/opencv-3.4.16/include",
            "C:/Program Files (x86)/aruco/include/aruco"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "windowsSdkVersion": "10.0.19041.0",
        "compilerPath": "cl.exe",
        "cppStandard": "c++17",
        "intelliSenseMode": "windows-msvc-x64",
        "configurationProvider": "ms-vscode.cmake-tools"
    }
],
"version": 4
}

So I am sure the include paths are correct because it shows them correctly in the left file, and the projects gets compiled too. Does anyone know any tricks I can get it to show them correctly in the other file? I don't really want to disable error squiggles entirely either.

BlueIceZ
  • 86
  • 1
  • 5
  • `c_cpp_properties.json` has nothing to do with compiling the program – rioV8 Jan 24 '22 at 12:17
  • Question is not about compiling. – BlueIceZ Jan 25 '22 at 09:03
  • It has come to my attetion that this display error of include path only comes in the main.cpp, so it maybe related to that. independent of this, I have had some weird behaviour with the IntelliSense. So I'll leave this question here for the moment. – BlueIceZ Jan 25 '22 at 09:05

1 Answers1

0

I would like to point out that, as noted in this thread, IntelliSense will grab headers based around the path from compilerPath if this option is present in the c_cpp_properties.json.

From some personal testing with a similar issue involving Qt includes, this issue may be fixed by simply leaving out compilerPath entirely, as it is an optional field and forces IntelliSense to search the paths included in includePath. After this, I was able to re-add the compilerPath, so it's possible this is just a quirk with the way IntelliSense builds its database.

rioV8
  • 24,506
  • 3
  • 32
  • 49