How can I use gcc's -I command to add recursive folders

泪湿孤枕 提交于 2019-12-10 04:13:37

问题


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

I'm trying to use :!gcc -E myfile.c to view macro expansions, but myfile.c includes a whole bunch of other header files in different directories, and because I'm executing this command in vim, so I don't want to call a makefile, is there anyway to do this?


回答1:


If you are using Apple's GCC (or Clang), then you can use the following approach (which appears to be an extension):


the parameter's suffix will need /**

-IMON_DIRECTORY/**

Now everything under MON_DIRECTORY/ may be searched.

Obviously, this could hurt your build times and it can result in inclusion of the wrong file when files have the same name. So... use it sparingly!




回答2:


gcc has various ways to control the include search path, but I see nothing providing what you want. Note that you can use environment variables for that, it could be more convenient for you than the alternatives.



来源:https://stackoverflow.com/questions/12292707/how-can-i-use-gccs-i-command-to-add-recursive-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!