Richard Hartman wrote:
> based on my Microsoft experience, precompiled
> headers are a Bad Thing (tm).

Let me disagree slightly -- based on my years of Microsoft experience
and a year of Metrowerks experience, Microsoft precompiled headers are
Bad but Metrowerks' are Good.

> The problem with this is that if the pre-digested
> version was created with different conditionals,
> you'll never see the effect you're after

Right, using the precompiled headers that come with the compiler are a
bad idea in any environment, for exactly this reason.  Let me discuss
only the kind of precompiled headers you generate yourself.  This is the
case where I found Metrowerks a lot easier than Microsoft.

(stdafx.h?  #pragma hdrstop?  Microsoft is way too complex, unless they
redesigned it during the last few years.)

> unless you somehow force it to regenerate the precompiled
> header database.

In a CodeWarrior project, you just make a header file with all the
#defines and system #includes you need, and then tell CodeWarrior to
precompile it and use it as the target's prefix file.

> The compiler is supposed to be
> smart enough to recognize when something that
> requires this to be done has changed, but the key
> phrase in that sentance is "supposed to be". In
> my experience they never are

So far I haven't had any such problems.  But also I put in the header
only things that rarely/never change such as <Pilot.h>, a #define for
ERROR_CHECK_LEVEL, etc.  To handle different builds with different
settings (mainly ERROR_CHECK_LEVEL), make multiple targets in the
project and set up a custom precompiled header prefix file for each.

And even when tweaking the precompiled header, I've found the
CodeWarrior IDE seems to figure out all the dependencies ok.

> My advice: never use precompiled headers.  Compilation
> times may be marginally longer, but you'll know what
> you're getting.

My advice: never use the precompiled headers that come with the
compiler.  Read the docs to learn how to make your own.  Compilation
will speed up AND you'll know what you're getting.

--
Scott Johnson
(not speaking for)
Oracle Corporation

Reply via email to