views:

498

answers:

2

Problem

In CodeGear C++Builder 2009 we are using the pre-compiled header injection to greatly reduce our compile times. We have the same header file being injected into multiple projects. When compiling some projects, the compiler kicks out the following warning:

[BCC32 Warning] Dateutils.hpp(43): W8058 Cannot create pre-compiled header: initialized data in header

In this example, the Dateutils.hpp is the file it's complaining about (CodeGear's header). I've seen this happen with other headers as well. What makes this interesting is that this only happens with some projects (same header being injected).

In the past, I've had to just find the header who ultimately included this errant file and remove it from my pre-compiled header file. Does anyone know what's going on here and the best way to fix it?

Update

I ended up performing a process of elimination approach to the header file and came up with an interesting finding that I cannot explain. Out of the 50+ headers that get included, when I removed vcl.h I no longer get the W8058 warnings. I do not understand this as I would imagine that this header file in particular is a prime candidate for pre-compiliation. Can anyone explain that?

+1  A: 

There are VCL header files that have this known issue: QC 23002. The marked severity on this item though is a "minor failure."

So the workaround options are limited:

  1. Not using those header files (which, yes, does defeat the idea)
  2. Modify the header files (not advisable -- hard to track changes, keep them current).

Either way, make sure that of the ones you come across, CodeGear has knowledge of those header files having that issue. That will certainly be the best way to address it long term -- let the vendor fix their problem. Supposedly CodeGear has DateUtils.hpp in their internal tests for this, but that was posted (for QC 2781) in July 2007. If the problem or certain header files affect you considerably, contact them about it.

Kris Kumler
+2  A: 

One thing that may be related is the way default string parameters are handled by BCB 200x.

Functions declared like this give the "can't generate precompiled header" message.

void myFunc(const AnsiString &param="");

However, change it to this, and the precompiled header can be generated.

void myFunc(const AnsiString &param = AnsiString(""));
Roddy
Really? Didn't know that and will definitely have to try it. Thanks!
Scott Saad