Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Oct 1999 22:44:57 -0400 (EDT)
From:      Chuck Robey <chuckr@picnic.mat.net>
To:        Thomas David Rivers <rivers@dignus.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: X11/C++ question
Message-ID:  <Pine.BSF.4.10.9910262242580.29073-100000@picnic.mat.net>
In-Reply-To: <199910270142.VAA31089@lakes.dignus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 26 Oct 1999, Thomas David Rivers wrote:

> > 
> > Does anyone (anyone, that is, who's coded X11 applications) know how you
> > handle X11 callbacks to C++ object methods?
> > 
> > Thanks,
> 
>  If you mean Xt (and possibly Motif) - the answer is "very carefully."
> 
>  The Xt callbacks are C based, so you typically can't directly call a 
>  C++ method.
> 
>  But, you can have an extern "C" block that declares the call back
>  function (the extern "C" basically keeps any name mangling from going on)
>  and then, in that function, invoke the method as appropriate.
> 
>  I believe you do something like:

[example deleted]

Then you just stick a C wrapper function around every C++ callback you
want to register, is that it?  Seems a bit inelegant, but I suppose, if
the ultimate test of elegance is that "it's the only one that works", then
it's perhaps elegant *enough*.

----------------------------------------------------------------------------
Chuck Robey                | Interests include C programming, Electronics,
213 Lakeside Dr. Apt. T-1  | communications, and signal processing.
Greenbelt, MD 20770        | I run picnic.mat.net: FreeBSD-current(i386) and
(301) 220-2114             |       jaunt.mat.net : FreeBSD-current(Alpha)
----------------------------------------------------------------------------



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9910262242580.29073-100000>