IntelliSense uses c_cpp_properties.json >> includePath to find the headers for auto-completion, but I noticed I still need to specify the include path inside the task.json >> tasks >> args to build.
I found in the documentation that the includePath is pretty much the same path I would specify in "-I":
The paths that you specify for this setting are the same paths that you would send to your compiler via the -I switch. When your source files are parsed, the IntelliSense engine will prepend these paths to the files specified by your #include directives while attempting to resolve them. These paths are not searched recursively.*
- Am I setting up VSCode correctly by specifying all the libraries and the includes directories inside the args of the build taks ? Or should it be done differently ?
- Can someone explain using different words what's the difference between the includePath and browse ? The explanation link is not totally clear to me
Here is an example of my 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
}
and 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",
"-ID:\github\dependencies\SDL2-2.0.8\include",
"-LD:\github\dependencies\SDL2-2.0.8\lib\x64",
"-lSDL2main","-lSDL2", "-lopengl32",
"-o",
"test-sdl"
]
}
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":"$gcc"
}
Is a simple question, but I am new to VSCode (sorry).
Question&Answers:os