December 11, 2002
Site Changes

I spent some time revising the design of the C++ Templates pages. It now fits better with the looks of the rest of the site.

I'm working on a Forum section that should allow me to more regularly write some things about templates in general. I already have a note prompted by reader feedback, but I'll wait to add it until everything is in place.

Posted by Daveed at 12:41 AM | Comments (2)

RE : Precompiled headers VS instantiate when used
In your book C++ Templates, 6.5 "Precompiled Headers", you mentioned something important ( for me ) :

... While doing so, the compiler may also generate code in object files.

I think there is a interaction between the intermediate object files generation
of precompiled headers and the template feature that "for class templates, only those member functions that are called are instantiated."

I observed while using VC6 on the Boost Graph Library that when I add new functionality in my code, that in turn uses more member functions
in the BGL, the first precompiled effort produced object code that did not contain the newer member functions required. Thus, I get strange link errors, and sometimes compile errors.

I found that it is simpler to just turn off the precompiled header option.
In short, use it in production builds but not while in iterative development

Am I taking too drastic a step? Are there other alternatives to consider?


Posted by: Kwee Heong Tan on August 19, 2003 02:49 PM

(In response to Kwee Heong Tan's message of August 19.)

Well, precompiled headers (PCHs) are certainly meant to primarily help with incremental builds. So if you cannot use them in "iterative development mode" the PCH mechanism has really failed.

Now, PCHs are really meant for header files, and normally header files should not generate code in object files (i.e., header files usually do not contain definitions of variables or non-inline functions). In particular you might want to make sure that you don't accidentally precompile parts of your dot-C files (or header files that really contain dot-C file things). Many PCH implementation provide a pragma (e.g., #pragma hdrstop) to help with that.

Posted by: Daveed Vandevoorde on August 21, 2003 02:10 PM
Post a comment

Email Address:



Remember info?