This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problems using gsl routines in C++ objects


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]