IntelliSense使用c_cpp_properties.json >> includePath查找自动完成的标头,但我注意到我仍然需要在task.json >> task >> args内部指定包含路径来进行构建。
我在文档中发现includePath与我在“ -I”中指定的路径几乎相同:
您为此设置指定的路径与通过-I开关发送给编译器的路径相同。解析源文件后,IntelliSense引擎会在尝试解析它们的同时,将这些路径添加到您的#include指令指定的文件之前。这些路径不是递归搜索的。*
这是我的c_cpp_properties.json的示例:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/github/dependencies/SDL2-2.0.8/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}/**"
]
}
}
],
"version": 4
}
Run Code Online (Sandbox Code Playgroud)
和task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"main2.cpp", …
Run Code Online (Sandbox Code Playgroud)