Date: Tue, 26 Oct 1999 21:42:03 -0400 (EDT) From: Thomas David Rivers <rivers@dignus.com> To: chuckr@picnic.mat.net, freebsd-hackers@FreeBSD.ORG Subject: Re: X11/C++ question Message-ID: <199910270142.VAA31089@lakes.dignus.com> In-Reply-To: <Pine.BSF.4.10.9910262134050.29073-100000@picnic.mat.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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: class myclass { void mymethod(void * arg1) { cout << "Ha! I got to the class" << '\n'; }; } extern "C" { void callback_function(arg1) void *arg1; { /* Call the method */ myclass::mymethod(arg1); } } Then, you register "callback_function" as the Xt/Motif callback. I've at least "heard" of doing that kind of thing before... - Dave Rivers - 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?199910270142.VAA31089>