469,270 Members | 1,011 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

benefits of precompiled headers

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?

Jul 23 '05 #1
2 2121
<un*********@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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
Jul 23 '05 #2
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

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Asfand Yar Qazi | last post: by
4 posts views Thread by Andrew Ward | last post: by
reply views Thread by Bruno van Dooren | last post: by
20 posts views Thread by Bonj | last post: by
1 post views Thread by dt | last post: by
1 post views Thread by Alvo von Cossel I | last post: by
8 posts views Thread by Abubakar | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.