lkml.org 
[lkml]   [2008]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    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
    >
    > KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
    >
    > --

    I think that if:
    [A]
    <header1.h>
    /* no includes pure level A header */
    </header1.h>

    [B]
    <header2.h>
    #include "header1.h"
    /* Level B header depends on level A */
    </header2.h>

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

    [D]
    <source.c>
    #include "header3.h"
    use types from A, B, C
    </source.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
    header2.h.

    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
    rule.

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

    Just my $0.017
    Boaz

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

    \
     
     \ /
      Last update: 2008-11-05 18:51    [W:0.024 / U:183.176 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site