[lkml]   [2008]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [Patch] Always include <linux/types.h>
Jörn Engel wrote:
> Hardly any file in the kernel can be compiled without including
> <linux/types.h>, directly or indirectly. And I'd wager a beer that
> noone can find a non-trivial example. I couldn't.
> So instead of sprinkling even more #include <linux/types.h> everywhere -
> 140 headers in include/linux/ would need that to compile standalone -
> let us just pass it automatically.
> The existing 4000 odd includes for types.h, plus some 300 each for
> compiler.h and stddef.h, which get pulled through types.h, can get
> removed at leasure.
> diff --git a/Makefile b/Makefile
> index 6192922..8a3fb66 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -326,7 +326,8 @@ AFLAGS_KERNEL =
> # Needed to be compatible with the O= option
> LINUXINCLUDE := -Iinclude \
> $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
> - -include include/linux/autoconf.h
> + -include include/linux/autoconf.h \
> + -include include/linux/types.h
> --

I think that if:
/* no includes pure level A header */

#include "header1.h"
/* Level B header depends on level A */

#include "header2.h"
use some types of header1.h
/* Level C header depends on level B */

#include "header3.h"
use types from A, B, C

Then that's fine any other file that includes any one of A, B, or C will have
no problem compiling and headers include order does not matter. Actually it is
nice, since the reader of header3.h knows that it is derived/dependent work of

Now what happens in the future when at B #include "header1.h" is removed.
At C header3.h stops compiling. So here I think it is the programmer's decision.
If he thinks that usage of A types used at C are do to B and if B's implementation
changes to use another set of types, then also C should change with it. Then leave
it as above. If the programmer decides that there is independent use of A types
in C unrelated to B, then he should also include A directly. If in doubt just don't
include it.

In any case I'm still not breaking the self-contained / order-independent headers

So please don't do that, Most of these places you found are the A-B-C case

Just my $0.017

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2008-11-05 18:51    [W:0.146 / U:1.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site