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

Offline 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?

Thanks in advance.

Online stahta01

  • Lives here!
  • ****
  • Posts: 6613
    • My Best Post
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
C Programmer working to learn more about C++ and Git.
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

Offline 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."

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
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)

Offline 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?

Offline 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.

Offline thomas

  • Administrator
  • 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."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5177
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 ?

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
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 ?

TDragon have already posted it. :)
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.

Offline 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.

Thanks for your replies.

Offline thomas

  • Administrator
  • 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."

Offline 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).

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
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.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5177
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 ?

Offline 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