benefits of precompiled headers

Discussion in 'C++' started by unspammable@gmail.com, Mar 3, 2005.

  1. Guest

    Several C++ compilers now allow precompiled headers, supposedly as a
    compile-time optimization.
    I personally do not use them, although I code mostly in VC++ (which has
    a tendency to shove PCH down your throat), because:
    a. When headers are lumped together into one huge entity the code loses
    a sense of who-uses-what, or so it seems to me. I like to be able to
    know from the include directives of each file as much as I can about
    the dependecies of that file.
    b. I never noticed a significant speed advantage using PCH - although I
    never actually timed and compared.

    What are you opinions on the matter?
    Are there any known disadvantages to using PCH?
     
    , Mar 3, 2005
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > Several C++ compilers now allow precompiled headers, supposedly as a
    > compile-time optimization.
    > I personally do not use them, although I code mostly in VC++ (which has
    > a tendency to shove PCH down your throat), because:
    > a. When headers are lumped together into one huge entity the code loses
    > a sense of who-uses-what, or so it seems to me. I like to be able to
    > know from the include directives of each file as much as I can about
    > the dependecies of that file.
    > b. I never noticed a significant speed advantage using PCH - although I
    > never actually timed and compared.
    >
    > What are you opinions on the matter?


    Used properly, precompiled headers do perceivably improve compilation
    times. I think this is tangible.

    > Are there any known disadvantages to using PCH?


    What you mentioned: less clear dependencies. Although there are
    other ways to express these in C++ code, for example with namespaces.
    And regarding MS-provided headers, anyway, you can hardly really
    include "only what you want" (you're stuck with getting the
    big blobs with all the macros herein).


    Ivan
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
     
    Ivan Vecerina, Mar 4, 2005
    #2
    1. Advertising

  3. Guest

    Our project at work takes about 1/5 of the time to build if you use
    PCH. We put includes of all the reasonable static headers, such as
    those for windows or VCL or dialogs all into one file, and use that as
    the PCH. Most localized headers are left is includes AFTER the pragma
    that tells it the PCH are done.

    e.g.

    #include "CommonHeaderDB4.h" // system headers and non-changing
    headers, e.g. vcl.h
    #pragma hdrstop

    // Local headers
    #include "uTrainExpandRoute.h"
    #include "uLoadDistThread.h"
    #include "fTrainMgr.h"
    #include "uTrainSupport.h" //business logic of train for functions
    too small to get their own file
    #include "uCommonMain.h" //common variables including those
    related to projects
    #include "uEstimateVolume.h"


    Dean
     
    , Mar 4, 2005
    #3
    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. Asfand Yar Qazi

    pimpl or precompiled headers?

    Asfand Yar Qazi, Apr 29, 2004, in forum: C++
    Replies:
    6
    Views:
    517
    Siemel Naran
    Apr 30, 2004
  2. dont bother
    Replies:
    0
    Views:
    866
    dont bother
    Mar 3, 2004
  3. Phil
    Replies:
    4
    Views:
    732
    Gabriel Genellina
    Jan 17, 2010
  4. Ian
    Replies:
    2
    Views:
    2,104
  5. Geo Tavros
    Replies:
    0
    Views:
    155
    Geo Tavros
    Sep 11, 2009
Loading...

Share This Page