Board index » cppbuilder » W8058 Cannot create pre-compiled header: Initialised data in Header

W8058 Cannot create pre-compiled header: Initialised data in Header

Hello

I didn't know whether to post this here or in Language, decided on .ide

I was happily using BCB5 with pre-compiled headers and then it broke with
the above warning.

When adding a third-party component (developed in Pascal) to my form it
breaks the pre-compiled header generation.  The component adds
#include<blah.hpp> to my form's header file which contains the following
code:

// Borland C++ Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved

// (DO NOT EDIT: machine generated header) 'blah.pas' rev: 5.00

#ifndef blahHPP
#define blahHPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Menus.hpp> // Pascal unit
#include <Math.hpp> // Pascal unit
#include <ImgList.hpp> // Pascal unit
#include <ComCtrls.hpp> // Pascal unit
#include <Spin.hpp> // Pascal unit
#include <Forms.hpp> // Pascal unit
#include <ExtCtrls.hpp> // Pascal unit
#include <StdCtrls.hpp> // Pascal unit
#include <Controls.hpp> // Pascal unit
#include <Graphics.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <SysUtils.hpp> // Pascal unit
#include <Messages.hpp> // Pascal unit
#include <Windows.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit

//-- user
supplied -----------------------------------------------------------

namespace blah
{

<snip>

Quote
} /* namespace blah */

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace blah;
#endif
#pragma option pop // -w-
#pragma option pop // -Vx

#pragma delphiheader end.
//-- end
unit ----------------------------------------------------------------
#endif

After adding the control to my form BCB complains about initialising data in
headers in my own header files, specifically, default function arguments.
After removing these default arguments, it complains about values declared
in math.hpp.

Removing the component and associated header file from my form causes the
pre-compiled header file to be correctly compiled.

What is it about the component's hpp file that it causing my pre-compiled
headers to stop working?

Any ideas?

Thanks

David

 

Re:W8058 Cannot create pre-compiled header: Initialised data in Header


Quote
> Not really. You've snipped the one area of this header that might contain
> initialised data and provide the answer.

It's an hpp file created from a delphi component and apart from class
definitions, the only other items of note are:

    static const Shortint CHECKBOXSIZE = 0xe;
    static const short crHandPoint = 0xfffffff6;

there are no other initialisers.  Also, adding this header file to the
project causes W8058 warnings in my own headers (default function params)
which is odd, and then in math.hpp which is listed at the top of the
component's header.  I wondered whether it was caused by the following:

   #pragma delphiheader begin
  #pragma option push -w-
  #pragma option push -Vx

Quote
> As the help for this message says:
> ////
>   initialized data in header   One of the headers contained a global
> variable definition (in C, a global variable with an initializer; in C++
> any variable not declared as 'extern').
> ////

> And any declared variables are likely to be within the namespace
> declaration.

> IOW:Check the variable declarations.

> Things to look for:

>   int fred;
>   int fred=0;

I couldn't find any, there just appears to be type definitions

Quote
> ISTM that you are trying to get rid of the warning itself rather than the
> problem that gave rise to the warning. That's a rather poor (IMO) way of
> resolving a problem. As doctors advise:Cure the disease, not the symptoms
> :)

Whatever.  Either way, I need to ascertain what's causing the warning.  When
adding the component header file it gives the W8058 warnings in my own
header files, so something ain't right with the component header file, and
the W8058 warnings may not be the actual problem with the component's header
file.

Still invesigating...

David
Witney, UK
Team House of Wing.

Re:W8058 Cannot create pre-compiled header: Initialised data in Header


Quote
"Andrue Cope" <not.a.va...@email.address.sorry> wrote in message

news:VA.0000169d.00fbfa4f@email.address.sorry...

Quote
> David Perkins,

> > adding this header file to the
> > project causes W8058 warnings in my own headers (default function
params)
> > which is odd

We've had the same thing off and on and it definitely seems linked to
something in math.hpp, usually the static const declarations which should be
fine.  In general, builder seems to intermittenly complain about default
values in functions such as

int foo(int y, int x = 12);

with the warning about code in the header.  This AFAIK is valid C++.  The
funny thing is that it isn't consistent.  It seems to depend on the order of
the cpp includes in the project.cpp file.  The code works as expected , in
spite of the warning except that it stops using the PCH and results in
longer builds.

Re:W8058 Cannot create pre-compiled header: Initialised data in Header


Quote
> But it will be interesting to see what the problem is - obviously there is
> some issue and I can understand why it's annoying. I learnt about __int64
> initialisation the hard way as well..perhaps there are other issues.

I've been using Google Groups and commenting out swathes of header files and
the verdict is:

math.hpp !

specifically, these:

static const Extended MinSingle = 1.500000E-45;
static const Extended MaxSingle = 3.400000E+38;
static const Extended MinDouble = 5.000000E-324;
static const Extended MaxDouble = 1.700000E+308;
static const Extended MinExtended = 3.400000E-4932;
static const Extended MaxExtended = 1.100000E+4932;
static const Extended MinComp = -9.223372E+18;
static const Extended MaxComp = 9.223372E+18;

so I've commented them out  and it works fine now.  =:-O

A slightly safer option seems to be to change the #include <math.hpp> in the
third-party's component header to use math.h instead.  Still investigating
the possible ramifications.

Re:W8058 Cannot create pre-compiled header: Initialised data in Header


David Perkins,

Sounds like an issue similar to that of __int64. Builder must be
generated executable code for those initialisations rather than using
'hard coded' values.

--
Andrue Cope
[Bicester, UK]

Team Thai Kingdom

Other Threads