This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: problems using gsl routines in C++ objects
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: Daniel Rohe <d dot rohe at fkf dot mpg dot de>
- Cc: gsl list <gsl-discuss at sources dot redhat dot com>
- Date: Tue, 26 Feb 2002 20:39:48 +0000 (GMT)
- Subject: Re: problems using gsl routines in C++ objects
- References: <3C7BBDF2.8020502@fkf.mpg.de>
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