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.
我想在vscode中定义我的c/c++项目相对于我的工作区文件夹的包含路径。由于mainfolder在我工作的每个系统上都有不同的路径,所以我不希望总是更改配置文件。
I have the following folder strucure
我有以下文件夹结构
mainfolder
/include1
/include2
/project/workspacepathofVScode
So the folder I open with vscode is workspacepathofVScode
.
我用vscode打开的文件夹是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:
在我的配置文件c_cpp_properties中。我使用**/**/从我的工作空间中获取根2层以上的json,包括我的两个include文件夹,但它似乎不是正确的语法:
{
"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?
我如何定义与workspacepathofVScode相关的包含路径?如果不像我想的那样,你知道有什么办法吗?
1 个解决方案
#1
1
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
Vscode不直接支持相对路径,但是可以从包含绝对路径的路径变量开始,然后附加一个相对路径。请参见下面的bug讨论:无法解析包含与相关路径
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:
包含1的完整路径应该是:
"${workspaceRoot}/../../include1"
#1
1
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
Vscode不直接支持相对路径,但是可以从包含绝对路径的路径变量开始,然后附加一个相对路径。请参见下面的bug讨论:无法解析包含与相关路径
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:
包含1的完整路径应该是:
"${workspaceRoot}/../../include1"