Quoting Viktor Rosenfeld ([EMAIL PROTECTED]): > David Wright wrote: > > > Are you saying that the software you downloaded has .c files and some .h > > files specially for it? > > Exactly! > > > What I do in that case is to have all the .c > > and .h files in the current directory (whereever), and use > > something like (taken from a bash function) > > /usr/bin/gcc -DMODULE -D__KERNEL__ -I. -I/usr/local/src/linux/include \ > > -O2 -m486 -g -Wall -c $@ -o ${SOURCE}.o ${SOURCE}.c > > That actually worked out perfectly. I modified the Makefile so it would > pass -I/usr/src/linux/include to gcc and it used the header files there > instead of the ones in /usr/include. > > I'm just wondering, how gcc knows which ones it should use. Does it > even look in /usr/include anymore?
I believe so, but my -I options tell it to search . and the kernel include files first. If I were to compile an ordinary C program (I never do), I would leave them out, so getting /usr/include headers included instead. > What if I pass multiple -Is to gcc > (as you do in your example) and there are different versions of the same > header file? That's all handled by the incantations that wrap virtually every header file, eg: /* * Dynamic loading of modules into the kernel. * * Rewritten by Richard Henderson <[EMAIL PROTECTED]> Dec 1996 */ #ifndef _LINUX_MODULE_H #define _LINUX_MODULE_H [snip the actual headers] #endif /* _LINUX_MODULE_H */ Without this, almost any compilation would grind to a halt with endless circular inclusions. Cheers, -- Email: [EMAIL PROTECTED] Tel: +44 1908 653 739 Fax: +44 1908 655 151 Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA Disclaimer: These addresses are only for reaching me, and do not signify official stationery. Views expressed here are either my own or plagiarised.