external (userland) inclussion of <linux/*.h>

From: Robert Millan
Date: Sun Oct 05 2003 - 05:44:20 EST



Hi there,

It is well known that Linux headers, which distributors put in /usr/include
in order to be used by Glibc, are often abused and mistakenly included by
userspace programs that don't actualy need kernel-specific features.

For example, some programmers prefer to include <linux/limits.h> instead of
<limits.h> to get a limit macro and break for all non-Linux-based systems while
they are at it.

When including a header directly is a wrong thing, the general tendency is to
simply disallow it. For example, Glibc headers use preprocessor commands in
the style of:

#ifndef _STDIO_H
# error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
#endif

Since there are a few legitimate uses of <linux/*.h> for userspace programs,
one could allow such by using the proper macro, something like:

#ifndef _LINUX_SOURCE
# error "blah"
#endif

If you like the idea, I can send a patch for all this.

--
Robert Millan

"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."

-- J.R.R.T, Ainulindale (Silmarillion)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/