Set include paths of c/c++-project relative to workspace path in Visual Studio Code (.json configuration)

Viewed 8123

I'd like to define the include paths of my /-project in relative to my workspace folder. As mainfolder has a different path on every system I work on, and I don't want to always change the configuration file.

I have the following folder strucure

mainfolder
   /include1
   /include2
   /project/workspacepathofVScode

So the folder I open with vscode is workspacepathofVScode.

In my configuration file c_cpp_properties.json I used **/**/ to get from my workspace root two levels up, to include my two include folders, but it does not seem to be the correct syntax:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "**/**/include1",
                "**/**/include2",
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "**/**/include1",
                    "**/**/include2",
                ]
            }
        }
    ],
    "version": 2
}

How can I define the include paths relative to workspacepathofVScode? If it is not possible the way I thought, do you know any workaround?

1 Answers
Related