VScode中的includepath配置
时间: 2023-09-24 20:10:57 浏览: 83
在VScode中,我们可以通过配置includepath来指定头文件的搜索路径,具体操作如下:
1. 打开VScode,在工作区文件夹中创建一个名为“.vscode”的文件夹。
2. 在“.vscode”文件夹中创建一个名为“c_cpp_properties.json”的文件。
3. 在“c_cpp_properties.json”文件中加入以下配置:
```json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt",
"C:/Program Files (x86)/Windows Kits/8.1/Include/shared",
"C:/Program Files (x86)/Windows Kits/8.1/Include/um",
"C:/Program Files (x86)/Windows Kits/8.1/Include/winrt"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"WIN32"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceFolder}",
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt",
"C:/Program Files (x86)/Windows Kits/8.1/Include/shared",
"C:/Program Files (x86)/Windows Kits/8.1/Include/um",
"C:/Program Files (x86)/Windows Kits/8.1/Include/winrt"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 2
}
```
其中,includePath字段指定了头文件的搜索路径,可以根据自己的需要进行修改。
4. 保存文件后,重新打开工作区,VScode会自动识别配置文件并加载头文件搜索路径。
注意:以上配置文件中的路径是针对Windows平台的,如果你是在其他操作系统上使用VScode进行C++开发,需要相应地修改路径。
阅读全文