Visual Studio Code: How to configure includePath for better IntelliSense results

Viewed 127376

I am a complete beginner to using Visual Studio Code and I have no clue what I am doing.

I've searched around (maybe not enough), but I can't find just a simple explanation for someone like me on how to configure the c_cpp_properties.json file that I am redirected to whenever I click on the yellow light bulb next to a line that is underlined with a green squiggle.

Lightbulb example

c_cpp_properties.json

I just want to know what to put in the .json to make IntelliSense work properly.

3 Answers

VSCode is very adept at asking the compiler what include paths it is using if you set things up correctly. Part of my project uses a DSP compiler based on GCC, so by adding "-v" to the compiler's flags (I put it in CFLAGS in my Makefile) I was able to see the internal command lines which revealed the "secret" flags being passed to the lower compiler levels. This showed me what "-D" values I needed to add to the "defines" section of my config and, more importantly, that "-isystem" was being used to set the system include directory. I ended up with this in my c_cpp_properties.json:-

{
    "configurations": [
    {
        "name": "CEVA-V15",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "defines": [
            "CEVAXC323",
            "XC323_CEVA"
        ],
        "compilerPath": "/devtools/CEVA-ToolBox/V15/CEVA-XC/cevaxccc",
        "cStandard": "gnu11",
        "cppStandard": "gnu++14",
        "intelliSenseMode": "linux-gcc-arm",
        "compilerArgs": [
            "-isystem /devtools/CEVA-ToolBox/V15/CEVA-XC/include"
        ]
    }
    ]
}
Related