How to resolve include file names conflicts in GCC?

寵の児 提交于 2019-12-22 11:15:16

问题


I have two header files named string.h in different libraries, they are conflicted with each other and even conflicted with standard C include file of the same name.

There is no need to use any string.h except standard one, but I need to include libraries headers paths in GCC search path. Currently I use something like -I /usr/local/include/lib1 -I /usr/local/include/lib2, but that way I can not include standard C string.h.

What is the right way to resolve such conflicts?


回答1:


You can probably use #include <lib1/string.h> and compile with gcc -I/usr/local/include.




回答2:


The problem is that directories added to the search path via -I get looked up before the standard ones which for gcc are (in order)

/usr/local/include/
/usr/include/
/usr/local/lib/
/usr/lib/

So you can follow Schnouki's advice, except that there is no need to add -I/usr/local/include



来源:https://stackoverflow.com/questions/2665979/how-to-resolve-include-file-names-conflicts-in-gcc

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