'C include file in VS code
I'm trying to write a simple C program using VS code; there are 3 files in my program.
"main.c", "test.c", "test.h"
the "main.c" file is located in the workspace directory and "test.h" file is in the header folder and this folder is located in the workspace directory. I want to include "test.h" in "main.c" file but I get the following error:
"fatal error: test.h: No such file or directory".
I have searched a lot and try many solutions but I could not solve this problem. I will appreciate any kind of help.
this is "c_cpp_properties.json" file:
{
"configurations": [{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}\\header"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "8.1",
"compilerPath": "C:\\mingw\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}],
"version": 4
}
this is "task.json" file:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\mingw\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"${workspaceFolder}\\source\\test.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\mingw\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
