### Author Topic: Compiling precompiled headers file with Code::Blocks  (Read 10314 times)

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Compiling precompiled headers file with Code::Blocks
« on: August 23, 2007, 09:24:48 pm »
I am trying to compile the precompiled header file wx_pch.h. The following are its contents:

Code: [Select]
`#ifndef __WX_PCH_H_INCLUDED__#define __WX_PCH_H_INCLUDED__#if ( defined(USE_PCH) && !defined(WX_PRECOMP) )    #define WX_PRECOMP#endif // USE_PCH// basic wxWidgets headers#include <wx/wxprec.h>#ifdef __BORLANDC__ #pragma hdrstop#endif#ifndef WX_PRECOMP #include <wx/wx.h>#endif#ifdef USE_PCH // put here all your rarely-changing header files#endif // USE_PCH#endif // __WX_PCH_H_INCLUDED__`
But I get alot of warnings of this kind:

Code: [Select]
`In file included from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/gdicmn.h:20,                 from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/msw/private.h:213,                 from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/msw/wrapcdlg.h:18,                 from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/wxprec.h:47,                 from src/wx_pch.h:9,                 from <command-line>:0:C:\prog32\sdk\wxWidgets-2.8.4\include/wx/list.h:506: warning: type attributes ignored after type is already defined`
and others of this kind:

Code: [Select]
`In file included from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/wx.h:19,                 from C:\prog32\sdk\wxWidgets-2.8.4\include/wx/wxprec.h:68,                 from src/wx_pch.h:9,                 from <command-line>:0:C:\prog32\sdk\wxWidgets-2.8.4\include/wx/hash.h:117: warning: attributes ignored on elaborated-type-specifier that is not a forward declaration`
I am using mingw32 gcc-4.2.1-sjlj compiler.
wxWidgets have been build with the same compiler, in release mode, in unicode, with opengl, xrc

Does anybody knows if this is normal? I am committing a mistake? Is there any way of getting rid of those warnings?

#### stahta01

• Lives here!
• Posts: 6667
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #1 on: August 24, 2007, 01:31:14 am »
Quote
warning: attributes ignored on elaborated-type-specifier that is not a forward declaration

That warning is normal in 4.2 GCC.

Tim S
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #2 on: August 24, 2007, 07:03:43 am »
But is there a kind of pragma or something to avoid them? I really hate having warning during the build of my code. I am a little fussy and like to see: "0 errors, 0 warnings."

#### TDragon

• Lives here!
• Posts: 936
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #3 on: August 24, 2007, 07:14:31 am »
Adding "-Wno-attributes" to the compiler options will get rid of most of the warnings. "-w" will suppress all warnings of any kind.
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #4 on: August 24, 2007, 07:21:26 am »
Well, is not that I want to suppress the warnings when they really exist, because some warnings can hide potential runtime errors. But get ridding *only* of those specific warnings that are supposed to be harmless and common would be nice. Does "-Wno-attributes" affects to those to warnings only?

#### wwolf

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #5 on: August 24, 2007, 09:50:50 am »
If this is a g++ problem, Code::Blocks cannot do much about it.  But you can write a little program, in Perl, Awk, or even C++ using the Boost::RegExp library to filter out those warnings - count how many you have filtered out, and update the warning number.   This means that you would call your wrapper instead of the g++ compiler, and the wrapper itself would run the compiler.  I have done something similar ages ago for the fake warnings from the SUN compiler.

#### thomas

• Lives here!
• Posts: 3979
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #6 on: August 24, 2007, 10:52:54 am »
I'm inclined to say that it is not a GCC/g++ problem, but a wxWidgets problem. They use long recursive macro chains that finally end up expanding to function attributes, and some of them are duplicate or in places where they shouldn't be, and the compiler tells you that it doesn't like it.

The good thing about it is that with this evil, ugly preprocessor hack, they somehow manage to compile their code on nearly every compiler from 15 year old ones to present ones. The bad thing is that you get so much noise, which effectively makes compiler warnings useless.
Compiling Code::Blocks with gcc 4.2 gives >2000 warnings from including the wxWidgets headers, compiling wxWidgets gives so many warnings that you cannot even count them (on the order of hundred thousands or millions).

Wwolf is right insofar as we can indeed not do much about it (nothing at all, actually). Just ignore it, or use the compiler option to turn off attribute warnings (this won't affect any other warnings).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

#### killerbot

• Lives here!
• Posts: 5193
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #7 on: August 24, 2007, 11:22:31 am »
Quote
Wwolf is right insofar as we can indeed not do much about it (nothing at all, actually). Just ignore it, or use the compiler option to turn off attribute warnings (this won't affect any other warnings).

I think we should do that, what is the option ?

#### Biplab

• Developer
• Lives here!
• Posts: 1874
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #8 on: August 24, 2007, 11:35:08 am »
I think we should do that, what is the option ?

Adding "-Wno-attributes" to the compiler options will get rid of most of the warnings.
Be a part of the solution, not a part of the problem.

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #9 on: August 24, 2007, 02:34:31 pm »
Well, I'll try the "-Wno_attributes" if this is the most convenient solution at hand.

#### thomas

• Lives here!
• Posts: 3979
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #10 on: August 24, 2007, 04:16:52 pm »
Quote
Wwolf is right insofar as we can indeed not do much about it (nothing at all, actually). Just ignore it, or use the compiler option to turn off attribute warnings (this won't affect any other warnings).

I think we should do that, what is the option ?
I think we should not do that. I makes building with 3.4.x impossible.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

#### wwolf

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #11 on: August 24, 2007, 05:10:40 pm »
Some of you guys may want to check it with the wxWidgets people if they know about this problem.  Maybe they have it in the plans to address it?  If not, maybe some user of Code::Blocks may contribute there.  I won't, because I do not know enough about wx, I just installed Code::Blocks few days ago (and had no time to play with it much yet).

#### Biplab

• Developer
• Lives here!
• Posts: 1874
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #12 on: August 24, 2007, 05:55:14 pm »
Some of you guys may want to check it with the wxWidgets people if they know about this problem.  Maybe they have it in the plans to address it?  If not, maybe some user of Code::Blocks may contribute there.  I won't, because I do not know enough about wx, I just installed Code::Blocks few days ago (and had no time to play with it much yet).

AFAIK, they are aware of this problem.
Be a part of the solution, not a part of the problem.

#### killerbot

• Lives here!
• Posts: 5193
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #13 on: August 24, 2007, 08:29:36 pm »
Quote
Wwolf is right insofar as we can indeed not do much about it (nothing at all, actually). Just ignore it, or use the compiler option to turn off attribute warnings (this won't affect any other warnings).

I think we should do that, what is the option ?
I think we should not do that. I makes building with 3.4.x impossible.

3.4.x fails to build then ?

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #14 on: August 24, 2007, 09:02:54 pm »
The '-Wno-comment' worked like a charm. Thanks again.

I've been reading about warning options of gcc and also have used the next options for avoid some warnings from some directx9 header files:

-Wno-comment
-Wno-unknown-pragmas

#### thomas

• Lives here!
• Posts: 3979
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #15 on: August 25, 2007, 01:41:58 pm »
Quote
Wwolf is right insofar as we can indeed not do much about it (nothing at all, actually). Just ignore it, or use the compiler option to turn off attribute warnings (this won't affect any other warnings).

I think we should do that, what is the option ?
I think we should not do that. I makes building with 3.4.x impossible.

3.4.x fails to build then ?
-Wno-comment was added with gcc 4.1, so both the 3.4 and 4.0 series will fail with "unknown command line switch" if you add that to the project/makefile.

It's ok for someone to use the flag if he only wants use gcc 4.2 anyway... but I think we should not use it.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

#### killerbot

• Lives here!
• Posts: 5193
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #16 on: August 25, 2007, 01:53:39 pm »
I'll see if I can do it with scripting ;-)

#### Biplab

• Developer
• Lives here!
• Posts: 1874
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #17 on: August 25, 2007, 01:58:28 pm »
I'll see if I can do it with scripting ;-)

There is a SDK function, CompilerMINGW::GetVersionString(). It'll return the version string of GCC (e.g., 4.1.2). You can use it somehow.
Be a part of the solution, not a part of the problem.

#### killerbot

• Lives here!
• Posts: 5193
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #18 on: August 25, 2007, 04:17:08 pm »
yes indeed, an when we know it's above 4.2 we add the little option to the compiler.
Just need to check with the big boss, if it is ok, to have a codeblocks.script next to our codeblocks.cbp ;-)

#### thomas

• Lives here!
• Posts: 3979
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #19 on: August 25, 2007, 05:50:10 pm »
Why an extra file? You could [[  ]] it as pre-build step for the first target.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

#### killerbot

• Lives here!
• Posts: 5193
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #20 on: August 25, 2007, 10:56:58 pm »
Why an extra file? You could [[  ]] it as pre-build step for the first target.
now that's something I didn't know

#### yakumoklesk

• Multiple posting newcomer
• Posts: 34
##### Re: Compiling precompiled headers file with Code::Blocks
« Reply #21 on: August 26, 2007, 03:10:26 pm »
It would be nice if another workaround is found rather of the -"Wno_attributes" option. I like the most warnings that are really warnings to be shown, and only mask the warnings that one knows to be sure that are harmless.