On Tue, Apr 01, 2014 at 06:35:59PM +0800, Nala Ginrut wrote:
> On Thu, 2014-03-27 at 21:03 -0700, Eduardo Acuña wrote:


Slightly reordered ....

> 
> Sorry I can't help you on this. IMO, you don't understand why you can't
> cast it as a function pointer. Maybe it's different from C?

Yes, somehow C++ happens to be different from C ;-)

> > My program calls scm_boot_guile from the member function init() of the
> > GuileApplication class. There is no problem passing the argc and argv
> > to scm_boot_guile, however i want to pass the member function
> > guileMain as the third argument of scm_boot_guile like a void function
> > pointer (i can't cast the member function as a function pointer). The
> > current way i'm avoiding this problem is passing as the third argument
> > a function outside of the GuileApplication class, and passing the
> > address of the instance of the GuileApplication as the fourth argument
> > for dereferencing the object and calling the guileMain member function
> > from there, so i had to make this non-member function a friend of
> > GuileApplication. This method works but it doesn't seem to be a clean
> > way of doing things.

I'd do this slightly different: instead of using a non-member function (which
needs to be declared a friend) I'd rather give my object a static function -
static functions _can_ be used as C callbacks (since they don't expect a 
hidden instance as the first parameter). You'd still need to pass down an
instance of your GuileApplication class so it can be handed to scm_boot_guile
as the data parameter. This is asdmittedly only slightly better than your 
solution.
 
HTH Ralf Mattes


Reply via email to