Reputation: 25232
I'd like to define the include paths of my c/c++-project in vscode 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?
Upvotes: 8
Views: 12122
Reputation: 13458
Vscode doesn't support relative paths directly, but it is possible to start with a path variable containing an absolute path and then append a relative path. See the following bug discussion: Unable to resolve includes with relative paths
So for the presented case of paths thats should be relative to the workspace path, start with the workspace path variable and use ".."
instead of "**"
to navigate to parent folders.
The complete path for include1
should be:
"${workspaceRoot}/../../include1"
Upvotes: 7