From owner-freebsd-hackers Tue Oct 26 18:42:18 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp2.vnet.net (smtp2.vnet.net [166.82.1.32]) by hub.freebsd.org (Postfix) with ESMTP id C097314C2D for ; Tue, 26 Oct 1999 18:42:14 -0700 (PDT) (envelope-from rivers@dignus.com) Received: from dignus.com (ponds.vnet.net [166.82.177.48]) by smtp2.vnet.net (8.9.1a/8.9.1) with ESMTP id VAA15841; Tue, 26 Oct 1999 21:42:05 -0400 (EDT) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by dignus.com (8.9.2/8.8.5) with ESMTP id VAA48948; Tue, 26 Oct 1999 21:42:03 -0400 (EDT) Received: (from rivers@localhost) by lakes.dignus.com (8.9.3/8.6.9) id VAA31089; Tue, 26 Oct 1999 21:42:03 -0400 (EDT) Date: Tue, 26 Oct 1999 21:42:03 -0400 (EDT) From: Thomas David Rivers Message-Id: <199910270142.VAA31089@lakes.dignus.com> To: chuckr@picnic.mat.net, freebsd-hackers@FreeBSD.ORG Subject: Re: X11/C++ question In-Reply-To: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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