Re: how gcc -I works?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux