Subject: Re: is obsolete?
To: walt <wa1ter@myrealbox.com>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: current-users
Date: 03/10/2006 12:46:14
walt <wa1ter@myrealbox.com> writes:

> For example, take this snippet from /usr/include/sys/msg.h:
> #include <sys/systm.h>
> 
> Given that _KERNEL is defined (as it is in libgtop2) what is
> cpp supposed to do with that line?  How/why would it look anywhere
> but /usr/include?  (I understand that the <> brackets mean that
> the header is to be found in /usr/include -- am I mistaken about
> this?)

The kernel compilation process explicitly specifies where to get files
for #include <foo.h>; take as an example this line from a typical i386
kernel build.

cc -ffreestanding -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wreturn-type -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -fno-zero-initialized-in-bss -Di386 -I. -I../../../../arch -I../../../.. -nostdinc -DLKM -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -I../../../../lib/libkern/../../../common/lib/libc/quad -I../../../../lib/libkern/../../../common/lib/libc/string -I../../../../lib/libkern/../../../common/lib/libc/arch/i386/string -I../../../../dist/ipf -c ../../../../nfs/nfs_subs.c

The "-I../../../.." refers to the top level of the kernel sources,
src/sys, so "#include <sys/systm.h>" will get src/sys/sys/systm.h, not
/usr/include/sys/systm.h, and thus (for this purpose) you don't need
to have the latter.

        - Nathan