Re: [glade--]Incorporating workaround for GCC 2.95.x dynamic_cast bug

Christof Petig <[email protected]> Mon, 26 Jan 2004 10:02:36 +0100
Newsgroups gmane.comp.gnome.glademm
Organization Adolf Petig GmbH & Co. KG
Message-ID <[email protected]>
Ansgar W. Konermann schrieb:
> Hello everybody,
> 
> a bug in GCC 2.95.x causes a segmentation violation when running
> c++ code generated by glade--. Details can be found here:
> 
> http://bugzilla.gnome.org/show_bug.cgi?id=78578  (please read)
> 
> There's a straightforward workaround for this: simply do not add child
> widgets inside the default constructor. Glade-- does this, however.
> 
> I'd like to have all source code generated by glade-- to be usable
> with gcc 2.95, so i'd like to change the code generation of glade--
> a little bit.

Please rethink your strategy. I decided to drop support for 2.95 two 
years ago, because a lot of interesting C++ template constructs are not 
possible (and not all standard compliant code does compile).

Even g++ 3.0 (debian woody) is enough to be usable with glademm and I 
never ever regretted my switch to the new vendor independant standard 
3.2/3.3 . 2.95 is dead. Not many people care to make C++ programs work 
with this compiler's limitations.

Unless you have really good reasons (not wanting to compile the compiler 
and the libraries by hand is not a that good reason) you should switch 
to 3.x sooner than later. 3.4 will give you precompiled headers (that 
should be enough incentive).

There has been some discussion about 3.x needing more memory or time 
(true, you might turn to -O0 if you want to get your object file fast) 
but the generated code is regarded being much faster on current 
processor architectures. Also the standard compliance costed g++ some speed.

> 
> Instead of adding child widgets inside the default constructor, I
> want glade-- to:
> * in <ClassName>_glade.(cc|hh), create a protected member function
>   named create<ClassName>Childs() which contains all the child
>   construction code (moved from the constructor)
> * call this code from the constructor of my derived class (named
>   <ClassName>.cc
> 
> This looks very simple to me, and if it's done manually is not a
> lot of work. However, I'd like to have this done automatically by
> glade--.
> 
> I understand from the source code that there's a state machine involved,

state machine? only for source code generation (indentation).

> and that there exists a class containing all the code generation stuff
> (Cxx). But I'm a bit overwhelmed by that code and don't know where to
> make the appropriate changes/additions to move the child widget
> construction code into a separate member function, and to call this
> member function from my derived class.

You should look into CXX_Fileset.cc (function WriteClasses). It's 
somewhat lengthy but reasonably commented.

This function should be all you need to modify.

    Christof