Precompiled Header(s)

Discussion in 'C++' started by ma740988, Jan 5, 2008.

  1. ma740988

    ma740988 Guest

    Section 6.5 of Josuttis, C++ Templates states - and I paraphrase.


    "Let's assume for the sake of argument that every file to be compiled
    starts with the same N lines of code. We could compile these N lines
    and save the complete state of the compiler at that point in a so-
    called precompiled header. Then, for every file in our program, we
    could reload the saved state and start compilation at line N+1."

    Josuttis, went on to state that "In practice this measn the files must
    start with the same #include directives, which consume a substantial
    portion of our build time".

    So given a file called 'std.hpp'. For discussion purposes assume
    std.hpp contains the following.

    # include <iostream>
    # include <string>
    # include <vector>
    # include <deque>
    # include <list>

    Later: foo.cpp
    # include "std.hpp"

    template < typename T >
    void confused ( const std::vector < T >& bogus ) {
    // stuff
    } // end confused


    At issue: How can I 'save the complete state of the compiler" such
    that any / all changes made to confused wont result in re-compilation
    of std.hpp?
    ma740988, Jan 5, 2008
    #1
    1. Advertising

  2. "ma740988" <> wrote in message
    news:...
    :
    : Section 6.5 of Josuttis, C++ Templates states - and I paraphrase.
    :
    :
    : "Let's assume for the sake of argument that every file to be compiled
    : starts with the same N lines of code. We could compile these N lines
    : and save the complete state of the compiler at that point in a so-
    : called precompiled header. Then, for every file in our program, we
    : could reload the saved state and start compilation at line N+1."
    ....
    : At issue: How can I 'save the complete state of the compiler" such
    : that any / all changes made to confused wont result in re-compilation
    : of std.hpp?

    Some compilers just happen to implement a precompiled headers feature,
    which may be configured/implemented in various ways.

    The complier may for example allow you to specify a special compilation
    flag for some files that will trigger the generation of precompiled
    header data. Other files, with a different compilation flag, are
    then configured to use and load a precompiled header information.

    This is all compiler-specific. For more specific information, please
    check your compiler's documentation, or ask in a forum dedicated
    to the compiler/platform you use.

    Ivan
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
    Brainbench MVP for C++ <> http://www.brainbench.com
    Ivan Vecerina, Jan 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Niiranen Miika

    Parameterized precompiled modules

    Niiranen Miika, Oct 7, 2004, in forum: VHDL
    Replies:
    1
    Views:
    544
    Jim Lewis
    Oct 7, 2004
  2. Steve Franks
    Replies:
    11
    Views:
    27,656
    JeanCastNet
    Jun 10, 2010
  3. Replies:
    0
    Views:
    398
  4. George2

    precompiled header file

    George2, Mar 29, 2008, in forum: C Programming
    Replies:
    0
    Views:
    290
    George2
    Mar 29, 2008
  5. mlt
    Replies:
    2
    Views:
    828
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page