help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Re: Help-gsl Digest, Vol 8, Issue 15


From: Matthew Collette
Subject: [Help-gsl] Re: Help-gsl Digest, Vol 8, Issue 15
Date: Wed, 30 Jun 2004 18:01:07 +0100 (BST)
User-agent: SquirrelMail/1.4.2

Dear Indrajit,
   I faced a similar problem with pointers to member functions for
integration and root solving. When using GSL with C++ member functions,
I have been using bridging static member function.  Basically, a static
member function has the correct layout in memory to be passed as a C
function pointer.  So I created a static member function that does
nothing other than call the C++ member function I was interested in,
and return the value from the member function.  It's not at all pretty,
and adds extra overhead, but it does work.  I've got a further
discussion and example class on my page at
http://www.students.ncl.ac.uk/matthew.collette/programs.htm, under the
GSL heading.  If others have a better way, I would be interested in
hearing about it.

Hope this helps,
Matt
---------------------------------------------
Matthew Collette, Phd Student
School of Marine Science and Technology
University of Newcastle, United Kingdom
Direct +44 (0)191 222 5534

> Subject: [Help-gsl] passing pointer to function from C++ to C in gsl
> This is more of a C++ help for passing member function pointers from C++
> to prototype written in C .
>
> I am using the GSL ODE solver(runga kutta methods) for some integration
> purpose. To cut the story short, could you please tell me what is wrong
> with this... as in why am I getting  this error
>
> adaptive.cpp:237: no matching function for call to
> `gslintegrator<ColumnVector<2,double>,2> :: defineSystem (int (adaptive ::
> *)(double, const double *, double *, void *), void *)'
>
> gslintegrator.hpp:281: candidates are:
> void gslintegrator<ColumnVector<2,double>,2>:: defineSystem(int
> (*)(double, const double *, double *, void *), void *)
>
>
> I am new at passing function pointers from C++ to C, and just looking at
> the above matching function and the candidate function I think they are
> matching.
>
> Can you please tell me if something needs to be taken care of while
> passing C++ member funciton pointers and collecting the pointers in C
> function pointer.
>
> I tried to find information on the net but no where was it given how to
> pass a class member function pointer to a C function pointer.
>
> Please help me.
> Thank you
>
> Indrajit Deshmukh
> Robotics and Mechatronics Lab
> ECE Department
> Clemson University
>
>
>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]