472,958 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 2265
<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Asfand Yar Qazi | last post by:
Hi, Now that GCC 3.4 has precompiled headers, I'm thinking I can stop using pimpls to speed up development time, as it may make life easier (declaring pimpls takes a long time...) What are...
1
by: JoeS | last post by:
Is there anyway to share a single pch file between projects in VC 7.0? I have 300+ projects each of which creates its own pch. All projects include the exact same header files in the precompiled...
4
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy...
0
by: Bruno van Dooren | last post by:
Hi, I am working on a dll that exports COM interfaces, and i am having some troubles with the use of precompiled headers. the project compiles always, but if i use /Yu (default: use precompiled...
20
by: Bonj | last post by:
Is it possible to avoid using precompiled headers on files that don't #include "stdafx.h". I have an ATL project,which has got a lot of ATL #includes in its stdafx.h. I now need to add some .c...
1
by: dt | last post by:
Having troubles with my program and i believe it has something to do with my project settings for precompiled headers. This is what i have: my main cpp file, vector.h/cpp and polygon.h/cpp. ...
0
by: citizenkahn | last post by:
I read an article entitled "Sharing precompiled headers between projects" on this group. I am in the same situation as the requesting author, but the solution has not worked for me. Here is my...
1
by: Alvo von Cossel I | last post by:
yo, i have a simple hello world win32 console application. it should work but there is an error. here is the most important part of the error: have you forgotten to add #include <stdfx.h> to...
8
by: Abubakar | last post by:
Hi, I am writing some unmanaged c++ code that would need to be compiled in the future using compilers other than vc++. I'm using the feature of vc++ "use precompiled headers", is there going to...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.