Author Topic: Building C::B with GCC 4.1.0  (Read 20446 times)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Building C::B with GCC 4.1.0
« on: February 01, 2006, 07:17:14 pm »
Hello,

I have tried to compile C::B + contrib. plugins with GCC 4.1.0 (from Ceniza) and it worked quite well :D. I got a lot of warnings regarding wxWidgets (I think that Ceniza said already something about this). Especially of this type:

Quote
wx/include/wx/string.h:58: warning: type attributes are honored only at type definition

C::B had some of these too.

Several warnings of this type too:

Quote
sdk/propgrid/include/wx/propgrid/propgrid.h:2352: warning: 'class wxPropertyContainerMethods' has virtual functions but non-virtual destructor

Some of this type:

Quote
sdk\propgrid\src\propgrid\propgrid.cpp:6804: warning: comparison is always false due to limited range of data type

and others, but less frequent.

But I also got errors, e.g.,:

Quote
sdk/manager.h:81: error: extra qualification 'Manager::' on member 'GetConfigManager'
sdk/configmanager.h:195: error: extra qualification 'ConfigManager::' on member 'Write'
sdk/editormanager.h:127: error: extra qualification 'EditorManager::' on member 'GetTree'
sdk/managedthread.h:14: error: extra qualification 'ManagedThread::' on member 'ManagedThread'
sdk/managedthread.h:15: error: extra qualification 'ManagedThread::' on member 'ManagedThread'
sdk/xtra_classes.h:22: error: extra qualification 'wxSplitPanel::' on member 'wxSplitPanel'
sdk/xtra_classes.h:25: error: extra qualification 'wxSplitPanel::' on member 'wxSplitPanel'
sdk/xtra_classes.h:37: error: extra qualification 'wxSplitPanel::' on member 'RefreshSplitter'
sdk/xtra_classes.h:39: error: extra qualification 'wxSplitPanel::' on member 'wxSplitPanel'

I have provided a patch to solve them, but I am not sure regarding the following:

Original:

Quote
wxPG_IMPLEMENT_PGMAN_METHOD_NORET1 (SetPropertyValue, const wxPoint&);
wxPG_IMPLEMENT_PGMAN_METHOD_NORET1 (SetPropertyValue, const wxSize&);
wxPG_IMPLEMENT_PGMAN_METHOD_NORET1 (SetPropertyValue, const wxArrayInt&);

Solution:

Quote
/*wxPG_IMPLEMENT_PGMAN_METHOD_NORET1*/void SetPropertyValue(const wxPoint&);
/*wxPG_IMPLEMENT_PGMAN_METHOD_NORET1*/void SetPropertyValue(const wxSize&);
/*wxPG_IMPLEMENT_PGMAN_METHOD_NORET1*/void SetPropertyValue(const wxArrayInt&);

Anyway, the patch is attached to this post (I prefer to know the opinions of the devs, before posting it to SF (if the devs think it is worth).

Could not be worthy to use GCC 4.1.0 for build C::B instead of the previous versions, e.g., 3.4.5, 3.4.4 and 3.4.2? Or it is too early and could have compatibility problems?

Best wishes,
Michael


[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Building C::B with GCC 4.1.0
« Reply #1 on: February 01, 2006, 08:10:41 pm »
propgrid also has this warning with the actual GCC (3.4.4)

I hope your patch get accepted, die warnings die ;-)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #2 on: February 01, 2006, 08:43:40 pm »
I hope your patch get accepted, die warnings die ;-)

Unfortunately, the patch just remove the errors :(. I hope anyway. Errors that I find a bit strange. Anyway, I think that some of the warnings could be relatively easy solved (at least the ones in C::B + contrib. plugins). I will work at it :).

Michael

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Building C::B with GCC 4.1.0
« Reply #3 on: February 02, 2006, 01:57:08 am »
The "extra qualification" errors are really evil, even more those introduced by the use of macros. I created a post about this issue in the developers forum when I uploaded that version of GCC but it got no attention (at least no about that specific issue).

I'm still waiting for the release of GCC 4.1.0 final, which seems to be pretty close, to provide binaries for it.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #4 on: February 02, 2006, 11:02:41 am »
The "extra qualification" errors are really evil, even more those introduced by the use of macros. I created a post about this issue in the developers forum when I uploaded that version of GCC but it got no attention (at least no about that specific issue).

I will check your post. Yes, those introduced with the macros are probably the worst. I will try if the "solution" that worked for me, still work with a previous GCC version. If yes, I will post a Patch to SF.

I'm still waiting for the release of GCC 4.1.0 final, which seems to be pretty close, to provide binaries for it.

That would be good :D. I think it is possible to use GCC 4.1.0 to clean/improve the code (especially from warnings).

Michael

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Building C::B with GCC 4.1.0
« Reply #5 on: February 02, 2006, 04:03:41 pm »
Quote from: Michael
I will check your post.

I think that's not possible. When I said "developers forum" I meant "developers only forum". I wonder if I also named it in the public thread :P

You'ren't missing anything really. I just named the problem, why and where it happened, but the only interest shown there was how I got to compile GCC 4.1.0 :)

I also hope your patch be accepted. It seems to be a matter of just a few weeks for GCC 4.1.0 final to be released, and it'll be surely available for Linux users first making Code::Blocks difficult to build there.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Building C::B with GCC 4.1.0
« Reply #6 on: February 02, 2006, 04:06:28 pm »
now just the guys ate MingW need to catch up. Some weeks ago they proposed 3.4.5 :-(
We want the 4.x .

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Building C::B with GCC 4.1.0
« Reply #7 on: February 02, 2006, 04:14:14 pm »
Quote
You'ren't missing anything really. I just named the problem, why and where it happened, but the only interest shown there was how I got to compile GCC 4.1.0 Smile
And I still have not managed to compile it... :(
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #8 on: February 02, 2006, 04:57:18 pm »
Quote from: Michael
I will check your post.

I think that's not possible. When I said "developers forum" I meant "developers only forum". I wonder if I also named it in the public thread :P

Ah ok, I understand :D.

You'ren't missing anything really. I just named the problem, why and where it happened, but the only interest shown there was how I got to compile GCC 4.1.0 :)

Could be this piece of information made available? It would be really good :D.

I also hope your patch be accepted. It seems to be a matter of just a few weeks for GCC 4.1.0 final to be released, and it'll be surely available for Linux users first making Code::Blocks difficult to build there.

The patch was nothing particular. Just taking out the offending "extra qualification" errors. And testing if the modifications done were still backward compatible with GCC3.4.4. That was all :).

Michael

pandapanda

  • Guest
Re: Building C::B with GCC 4.1.0
« Reply #9 on: February 07, 2006, 08:52:07 am »
Hello,

I have tried to compile C::B + contrib. plugins with GCC 4.1.0 (from Ceniza) and it worked quite well :D. I got a lot of warnings regarding wxWidgets (I think that Ceniza said already something about this). Especially of this type:

Best wishes,
Michael


you said "I have tried to compile C::B + contrib. plugins with GCC 4.1.0 (from Ceniza) and it worked quite well", can you tell me how to use this GCC 4.1.0 with step by step?

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #10 on: February 07, 2006, 10:57:09 am »
Hello,

I have used the GCC 4.1.0 that Ceniza has provided :D. Check here for more info. Practically you should download MinGW if you not have it already. I have installed version 5.0. Then you download Ceniza's package, unzip it and copy and paste the repositories in MinGW. In C::B under Settings-->Compiler and debugger-->Directories tab-->Compiler tab, you add:

Quote
C:\Programme\MinGW\include  --> if MinGW is installed in C:\MinGW, then change it in C:\MinGW\include
C:\Programme\MinGW\include\c++\4.1.0  --> if MinGW is installed in C:\MinGW, it is not necessary
C:\Programme\MinGW\include\c++\4.1.0\mingw32  --> if MinGW is installed in C:\MinGW, it is not necessary

That's all, at least with me. If you have some problems, just post here.

Anyway, after installing MinGW, you should let C::B autodects it and then check if the pathes it has set are correctly. Then you add GCC 4.1.0 and modify the compiler path (with me it was necessary to avoid file not found errors).

Best wishes,
Michael
« Last Edit: March 01, 2006, 12:45:13 pm by Michael »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #11 on: February 07, 2006, 06:19:23 pm »
Quote
sdk/propgrid/include/wx/propgrid/propgrid.h:2352: warning: 'class wxPropertyContainerMethods' has virtual functions but non-virtual destructor

Concerning this warning, I have found an interesting discussion in the Qt forum.

This FAQ could also be helpful. At least it was for me :D.

[EDIT]: I also got this advice from a C++ expert:
Quote
If your constructor does nothing: better not to define it. You can define a dummy destructor - but if you do it, define it as virtual.

Michael
« Last Edit: February 07, 2006, 06:30:52 pm by Michael »

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Building C::B with GCC 4.1.0
« Reply #12 on: February 09, 2006, 07:17:33 pm »
is gcc 4.1 really so much faster than gcc 3.4  on  windows platform  ??

has anyone done a comparison already ,  if so please post results.

any issues with using gcc 4.1 ??

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Building C::B with GCC 4.1.0
« Reply #13 on: February 09, 2006, 07:36:52 pm »
Hello,

Personally, I have not remarked a real speed difference between GCC 4.1.0 and GCC 3.4.4. The building time for C::B seems to be quite the same with both GCC 4.1.0 and GCC 3.4.4 (if we exclude the several warnings that GCC 4.1.0 displays: around 3600-3700 for C::B and 700-800 for contr. plugins. Until now C::B built with GCC 4.1.0 (debug) works not really faster that the same version compiled with GCC 3.4.4 (debug). May be a bit faster, but not so much.

Concerning the issues, I had to solve some with C::B, otherwise all seem to work well (until now :)).

Best wishes,
Michael

PS.: Anyway, the GCC 4.1.0 I am using (snapshot from Ceniza) is not the final release and this could have some influence.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Building C::B with GCC 4.1.0
« Reply #14 on: February 09, 2006, 08:24:49 pm »
I also got this advice from a C++ expert:
Quote
If your constructor does nothing: better not to define it. You can define a dummy destructor - but if you do it, define it as virtual.
This is actually quite a bad advice in my opinion. An empty constructor does not help, but it does not harm either.

On the other hand, a virtual destructor does harm. Maybe "harm" is the wrong word, let's say "cost", but the general idea is the same. At the very least, this bears an unnecessary storage cost of one pointer in the vtable plus one pointer for every allocated object. The single vtable entry may be neglegible, but if you allocate and deallocate 5 million objects, then carrying around one unnecessary v-ptr for each object may make a difference (as may the two additional pointer dereferences to call a destructor that does nothing...).
As always, the significance depends on what you do, but I think carrying around a penalty that you absolutely don't need is not a good idea.
You could say it is like using x++; or ++x;, the difference (if any) is not terribly big... but then, here we do bother ;)

The one and only case in which you really need a virtual destructor is when all of the following three conditions are met:
1. you have one or more virtual functions
2. you allocate an object of a derived class
3. you free this object as a type of the base class

For convenience, and for safety, one usually defines a virtual class' destructor virtual, as it does not make much difference (you have to carry the v-ptr around anyway) and you don't have to worry about who might derive from and tamper with your class.
However, it makes no sense at all to make a destructor virtual in a non-virtual class just for the sake of doing it.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."