I am putting together a simple C project in VS Code which would just compile a single C file using GCC compiler.
I have created a c_cpp_properties.json
and tasks.json
.
It is unclear to me where is the GCC compiler supposed to get include directories from.
When include dirs are added to c_cpp_properties.json
via the includePath
"configurations": [
{
"name": "Win32",
"includePath": [
"C:/include/path1",
"C:/include/path2"
],...
it doesn't work.
It only compiles successfully when I add the paths as compiler arguments to tasks.json
:
"tasks":
[
{
"label": "Compile C file",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"-I",
"C:/include/path1",
"-c",
"myfile.c"
],...
Where is the GCC compiler supposed to get include directories from?
What is the includePath
in c_cpp_properties.json
for?
c_cpp_properties.json
Reference Guide says:
- includePath:
If "C_Cpp.intelliSenseEngine" is set to "Default" in your settings file, this list of paths will be used by IntelliSense to search for headers included by your source files. This is basically the same as the list of paths you pass to your compiler with the -I switch. If a path ends with /** the IntelliSense engine will do a recursive search for includes starting from that directory. If on Windows with Visual Studio installed, or if a compiler is specified in the compilerPath setting, it is not necessary to list the system include paths in this list.