How to use gcc -I command to add recursive folders

Is there a way to use the gcc -I command and add all the paths to the search path by specifying the root directory?

I try to use :!gcc -E myfile.c to view macros, but myfile.c contains a whole bunch of other header files in different directories and because I execute this command in vim, so I don’t want to call the makefile, is there any way do it?

+4
source share
2 answers

If you are using Apple GCC (or Clang), you can use the following approach (which is an extension):


parameter suffix requires /**

 -IMON_DIRECTORY/** 

Now you can find everything under MON_DIRECTORY/ .

Obviously, this can damage the build time, and this can lead to the inclusion of the wrong file when the files have the same name. So ... use it sparingly!

+6
source

gcc has various ways to control the inclusion of the search path , but I don’t see anything providing what you want. Please note that you can use environment variables for this, it may be more convenient for you than alternatives.

+1
source

Source: https://habr.com/ru/post/1432620/


All Articles