Re: 2.2.1 header conflicts

Trevor Johnson (trevor@jpj.net)
Fri, 19 Feb 1999 14:52:05 -0500 (EST)


> #include <linux/nfs_fs.h>
>
> main()
> {
> return 0;
> }

> It seems as though there might be a conflict here. Is the preceding
> simple program false?

Hi, Dan. Usually it's best to use the kernel's headers (<scsi/...>,
<net/...>, <linux/...> and <asm/...>) only within the kernel or modules,
and the libc's headers only for applications. If you need something
that's not in the libc headers (and of course this simple program does
not), then one approach is to borrow just that section and put it in your
own header file (#include "my_nfs_stuff.h"), with a check that __linux__
is defined if you're using a Linux-specific feature. If it's something
that's only available in certain versions of Linux, you might check the
UTS_RELEASE or LINUX_VERSION_CODE in <linux/version.h>, making the
assumptions that the program will be run on the same system where it's
being compiled and that the headers in place reflect the kernel that's
being run. You might also offer it to the libc folks if you think it'll
be used much.

You might have a look at ddstar and autofs as examples.
__
Trevor Johnson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/