Re: Linux 2.6.0-test6

From: Jamie Lokier (jamie_at_shareable.org)
Date: 09/28/03

  • Next message: Jörn Engel: "Re: Linux 2.6.0-test6"
    Date:	Sun, 28 Sep 2003 20:44:05 +0100
    To: Linus Torvalds <torvalds@osdl.org>
    
    

    Linus Torvalds wrote:
    > On Sun, 28 Sep 2003, Sam Ravnborg wrote:
    > > Would it help to require all major[1] header files to include all the
    > > header files needed for them to compile?
    >
    > It causes tons of extra work for the compiler if the compiler doesn't
    > optimize away redundant header files (same header file being included from
    > a lot of different sources).
    >
    > I did the pruning in sparse, and I think at least gcc-3 does it too, but
    > I'm not sure.

    GCC does optimise away multiple header file inclusion, and has done
    for a very long time, oh a decade or so :)

    GCC will not reparse a header file if these conditions are met:

            1. The file has already been parsed at least once.

            2. Apart from comments, the entire file is surrounded by
               "#ifndef symbol ... #endif" or "#if !defined (symbol) ... #endif".

            3. "symbol" is defined.

            4. The file names are the same after removal of "." and ".." components
               and other path simplifications.

    > If so, then sure, we could just require that the header files compile
    > cleanly, and for extra points verify that the end result is an empty
    > object file (ie no bad declarations anywhere..).

    You can also use the "-H" option and check for a "Multiple include
    guards may be useful for:" message, to check those #ifndefs.

    -- Jamie
    -
    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/


  • Next message: Jörn Engel: "Re: Linux 2.6.0-test6"

    Relevant Pages

    • Re: header files
      ... As all code can be written in the header file ... > void foo() ... > compiler tries to compile main.c it eventually reaches the line ... > the compiler has never heared about a function called printf(). ...
      (alt.comp.lang.learn.c-cpp)
    • Re: include file question
      ... Where did you read that #pragma once is obsolete? ... because it suggests that what you need is some kind of weird compiler hack to make your ... inside the header file to prevent multiple execution of the contents. ... documentation about Objective C, which is a language which is NOT the C++ language, has ...
      (microsoft.public.vc.mfc)
    • Re: header files
      ... As all code can be written in the header file ... void foo() ... So when the compiler compiles ... the compiler has never heared about a function called printf(). ...
      (alt.comp.lang.learn.c-cpp)
    • Re: #include what?
      ... everyone did command line programming in something akin to a "shell". ... the compiler has to pick somewhere to look for the ... of a header file in the local directory and then hack it to override ... features of the old style that we lost with the modern interpretation. ...
      (comp.compilers)
    • Re: multiple file programs
      ... A header file acts as though the literal text within the file had been typed ... into your source file. ... that comes with your compiler. ... Libraries are used to minimize compile time and to reduce ...
      (alt.comp.lang.learn.c-cpp)

    Loading