vim include .h files from projects include directory - c

EDITED.
Is there a way so that vim detects the path of the header files without using relative paths in the source files like #include "../foo.h"
How to set the path option correctly for the current project folder and how to make a rule for it so that every project with that folder structure can profit?
Are there plugins for it?
I have a multifile c project. int the project folder is one src and one include folder. the src directory contains all .c files, the include folder inhabits all .h files.
project
|_ src
|_ include
example: main.c
#include "..\foo.h"
..
Vim knows about foo.h if the file is within the src folder, but not if it is in the include folder
I have tried setting the path variable in the .vimrc file with no luck.
All other includes from usr/include are working fine.

You must declare either a relative or Absolute path. So there is no "auto detection" just from a file name.
Side note: Vim doesn't care about your paths, the C Preprocessor Include cares about your paths

Related

VS Code cannot open source "graphics.h", although "C:/MinGW/libs/**" is added to includePath

So I'm trying to import this library to my code, so I copied the header files to my MinGW/include folder, then copied the library files to MinGW/lib, and finally added "C:/MinGW/include/**" to my includePaths in the C/C++ config file. Still thou, I'm getting the error that this header doesn't exist

Eslint configure for react

I am using eslint in a react project, I have .jsx, .js, .test.jsx, .test.js files, I want to configure my eslintrc.json file to such that, ,it check .js and .jsx files as well as ignore .test.jsx and .test.jsx file, how may I do that ?
Thanks for the help.
You can set a .eslintignore file, to ignore certain folders and files.
Refer document: ignoring-files-and-directories
You can tell ESLint to ignore specific files and directories by creating an .eslintignore file in your project's root directory.
The .eslintignore file is a plain text file where each line is a glob pattern indicating which paths should be omitted from linting.
For example:
src/serviceWorker.ts
src/react-app-env.d.ts

How to properly manage multiple include chains in a C project?

Noob question here. I have a C project with a lot of files. And each of these files have other files as dependencies. Right now, for each library, I've created a ".h" file and a ".c" file. The ".h" files have the function prototypes and macro-definitions and the ".c" files have the function definitions. My question is whether I should include other libraries required in the ".h" file or the ".c" file. Also, are variables defined in the ".c" file available in the global scope even though the ".h" file is included in the main program. How do I manage compiler conflicts from having the same file multiple times? Someone kindly explain the whole thing to me.

CodeBlocks header common folder

I have multiple projects which have the same header files over and over again, is it possible to create a common utils folder with all the headers and their source files?
Project files with header files
Yes, you can. First make a folder and insert all of your header file in that folder. then create a makefile and you can add that folder for the headers in a Makefile. See here
Other option can be to give path in include like
#include "../Headers/check.h"
#include "../Headers/stackstring.h"

Preserving Header Directory Structure in Xcode for Static Library

I'm developing a static library in C++ using Xcode. I have an Installation Directory set where it copies all of my public header files, but when I compile it just copies all the headers into one directory. Is there a way to tell Xcode to preserve the directory structure of my header files? Thanks in advance!
I also needed to preserve the header file directory structure for a C++ library project and I finally managed to do it. It is ridiculously complicated with XCode, compared to the simple nature of the task. The key is to create "folder references" at first, then to copy the header folders in an extra build phase and afterwards to delete .c/.cpp-files from these exported header folders with a script, because XCode will not only copy the .h-files.
I've written a blog post here on how to all achieve that, because it's more tricky in detail. You might also want to check out an example XCode project that I've pot on github.
When you add files to your project, you have to choose next parameter on an additional window "Create folder references for any added folders". And then all your files will have fixed path for your files and will save structure after compilation.

Resources