>           In various kernel source files,i came across '#ifdef _KERNEL'.
> What is '_KERNEL' used for ? In some files _KERNEL is #defined to nothing ??
> Can anybody please explain this ?

It is used to control the visibility of types and prototypes in system headers.
Kernel builds define _KERNEL, but userland compiles usually do not.  Thus a
#include <sys/foo.h> has a different meaning in userland than in the kernel.
See: src/sys/conf/{kern.pre,kmod}.mk

A few userland utilities (e.g., fstat) define _KERNEL before including
headers from <sys/*> because they need more knowledge of kernel
data structures than is the norm for userland.

--
FreeBSD Volunteer,     http://people.freebsd.org/~jkoshy
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to