Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Cannot create pre-compiled header: initialized data in header

 

Compile warning.

 

If you get this compile warning, compiling will be significantly slowed down. Luckily, the problem is easy to solve.

 

There are many ways to get this warning. Below I'll show how to cause one and how to solve all.

 

 

 

 

 

Full warning message

 

[C++ Warning] locale(150): W8058 Cannot create pre-compiled header: initialized data in header

 

 

 

 

 

Cause

 

#include <boost/lexical_cast.hpp>
#pragma hdrstop

 

Which takes you to the following line in 'include/stlport/locale':

 

#ifndef __LOCALE_INITIALIZED
#define __LOCALE_INITIALIZED
// Global initializer object, to ensure initialization of locale subsystem.
#ifndef __BORLANDC
static
#else
extern _STLP_DECLSPEC
#endif
ios_base::_Loc_init _LocInit; //This line
#endif

 

IDE: C++ Builder 6.0

Compiler: Borland BCC32.EXE version 6.0.10.157

Project type: VCL

Boost version: 1.35.0

 

 

 

 

 

Solution

 

Put the #include of the header that causes this behind the #pragma:

 

#pragma hdrstop
#include <boost/lexical_cast.hpp>

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict