This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how gcc -I works?


xu zhou wrote:
  I want to include header files from /usr/src/linux/include because
I want to compile a module. I use the gcc -I option. It include header
files from the correct path but the header files alse include header
files , and those header files are included from /usr/include which is
my common include path.  I don't know how to fix it , can anyone help
me ?


I dont think you are meant to use kernel header files directly so this is the rule you are breaking here. But if you insist then the following may help you.


Try using:


gcc -v -Iyourdir blah... blah...

To see where files are being included from and in what order.


Check out the options:


-nostdinc -nostdinc++


Then maybe reintroduce header files in the specific order you want.




Alternatively maybe the simplest trick is to add a symlink:

/usr/src/linux/kinclude -> include


To add -I/usr/src/linux



Then use:


#include <kinclude/linux/foobar.h>
#include <kinclude/asm/foobar.h>


You shove the verbatim linux kernel header files down the include file hierarchy one level with a new unique subdirectory name "kinclude" which doesn't clash with anything else.



Darryl



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]