Re: gripes, etc.

Karl Nelson wrote:

> > Karl Nelson wrote:
> [...]
> > > The
> > > Gtk C++ bindings are usable but the Gdk bindings are quite defective.
> > > These problems unfortunately can't be addressed in a stable version
> > > because C++ mangling issues.  Seeing as gtk+ 2.0 is not all that far
> > > off our current efforts for stable are limited to fixing the
> > > really broken things in the gnome-libs wrappers.  Active developement
> > > to the 1.3 port will begin as soon as the remaining major underlying
> > > changes (gobject) is done.
> >
> > Hmm, as for the mangling issue, for callbacks, what about using C callbacks
> > that interact with the C++ code?
> Using straight C++ linkages to C is generally considered bad in that
> member functions are not the same as a C static function (you can
> fake "this" but not at all portable.)  Generally, the only option
> is to make a template class like done in libsigc++ or have the user
> write 2 copies of every function (one to get called from C which
> spawns the C++ copy.)

Surely there has to be a better way.  I've yet to see something that couldn't be

> Mangling and binary compablity with C++ is a more complicated issue
> than just the callbacks.

Of course.  There is no standard to the mangling used in C++, is there?  Nor no
portable to find the mangled names...

> TrollTech has a great entry in their FAQ on this.
> For those reasons it is darn hard to get a C++ library to stable.
> To be considered stable you have to not change anything in the
> data structures or the procedures, nor change the types of any
> of the arguments.

Hmm... There has to be a way to do this.

> > I've seen a few programs that do this,
> > though I haven't much done anything like that myself (no real need for any of
> > my projects).  I also recently saw a library on Freshmeat for callbacks that
> > I believe handled C++/C interoperability, so maybe a search on Freshmeat for
> > something like "C++ callbacks" or whatnot would turn it up... It could be
> > useful, no?
> You mean libsigc++.  I hope it is useful as I wrote it for GNOME to
> make gtkmm easier to use.  :-)

No, not libsigc++ (which I haven't used at all... though I've thought about using
it in AweMUD).  There was another one that specifically handled the whole issue of
C/C++ inter function calls (which is mostly done with libraries and callbacks).
Although now that I think about it, it used a not very portable in any way
assembly file for setting up the stack for object methods and whatnot...  I doubt
there is a clean way of handling that.

What about generating a C function in place of the callback that takes a
void* data member (the pointer to the class of the callback) and when macking that
callback, use another method in the C++ code that takes the function pointer and
the void*, and properly sets up the stack from it: then it would be dependent on
the compiler that made the code, which is exactly what is needed.  Only that the C
code would have to be rewritten to use and understand the void* to the class, and
there'd need to be a way to export the address of the function used in the C++
code that calls the actual callback.  Either a C-recognizable function that
returns the address, or perhaps some kind of constant that is generated at compile
time, though I doubt that is overly possible (without a lot of architecture and OS
dependent code).

Even if the solution is a hack, is that all that bad if it works on all the
necessary platforms?  The one big rule is "it needs to always work everywhere it
should and always as it should."  Well, that's my one big rule... ~,^

This is something I'd love to look into if I'm given any time.  ~,^

> [...]
> > I haven't much used gtkmm.  Perhaps I'll take a look at it in my all too
> > sparse spare time.  The GTK/GNOME API is really nice, but C just isn't my
> > thing... ~,^
> Hopefully, you will find it slightly more sane.  Of course, if you don't
> you can always consider using any of the 5 other C++ wrappers for
> gtk+.

I'd prefer to use the most "standard" or "official" wrapper, so that there is a
higher percentage of people who have it installed on their system.  I'm training
myself to not mind using other people's libs, but I want them to be libs that the
users will actually have, or not mind having...

It's like WxPython, far better than TK in my opinion, but needing WxWindows +
WxPython + Python for just a simple app is a bit ludicrous... then again, Tk needs
TCL + Tk + Python, so maybe there's not that big of a difference.  Oh well, bad
example.  But you get what I mean, right?

Gtkmm seems to be the most widely accepted at the moment (it's officially
distributed with Helix Code, in any event), so its the one I'd use.

> --Karl

Sean Etc.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]