Re: XForms: C++ design wanted

Mark Edward Johnston (M.E.Johnston@damtp.cam.ac.uk)
Tue, 1 Jul 1997 16:33:18 +0100 (BST)

To subscribers of the xforms list from Mark Edward Johnston <M.E.Johnston@damtp.cam.ac.uk> :

On Sat, 14 Jun 1997, Mark Edward Johnston wrote:

> To subscribers of the xforms list from Mark Edward Johnston <M.E.Johnston@damtp.cam.ac.uk> :
>
> On Sat, 14 Jun 1997, Kaz Kylheku wrote:
>
> > Umm, what you are doing is passing a pointer to a C++ function to a subsystem
> > that expects a pointer to a C callback function. Doesn't that violate some
> > rule somewhere in the mighty C++ draft? ;)
>
> Well I think you're correct.

...well I don't think so anymore !

I asked about this on gnu.g++.help and comp.lang.c++ and the consensus
was that it is OK to pass a pointer to a C++ static member
function to a function which wants a pointer to a C function.
The essential difference between C and C++ functions is that the names
of the latter are mangled to allow overloading, so it would be
difficult for a C function to call a C++ function by name, but calling
one through a pointer is fine.

See the above newsgroups for the thread
"Can I use a C++ function pointer instead of a C one" if you're
interested.

One person gave the caveat that there might be a problem if the C and
C++ codes were compiled with different compilers, on some platforms,
but as far as I can tell from the gcc info files, such problems are
rare, and would be triggered by C code compiled by different compilers as
well.

So, it seems the example originally provided is OK.

Mark J.

---
Mark Johnston.                    M.E.Johnston@damtp.cam.ac.uk
816 King's College, Cambridge, CB2 1ST, U.K.
 or: DAMTP, Silver St., Cambridge, CB3 9EW, U.K.
'phone: (home) +44 1223 500 585 (has voice mail, let it ring!)
WWW: http://www.damtp.cam.ac.uk/user/mej20/

_________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuf2.usuhs.mil or see http://bob.usuf2.usuhs.mil/mailserv/xforms.html Xforms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/