problems using gsl routines in C++ objects

Brian Gough bjg@network-theory.co.uk
Tue Dec 31 09:55:00 GMT 2002


Daniel Rohe writes:
 > Hi there,
 >  I intend to pass a member function of an instance of some class X
 > to a gsl integration routine, which requires a pointer of "double
 > (*)(double , void *)" type. I have tried various things such as
 > passing "this->function" or even explicitely casting "double
 > (X::*)" to "double (*)", but I either get comilation errors or the
 > compiler automatically converts "double (X::*)" to "double (*)".

The calling convention for a C++ member function is implemented
differently from a C function I think, member functions involve some
kind of table address and offset -- so there's no way to cast one type
of pointer into the other.  The static member function technique just
posted seems like the way to go, since static member functions are
just ordinary C-style functions.

Brian



More information about the Gsl-discuss mailing list