Chris Swierczewski wrote: > I have a cdef'ed class with a cdef'ed method that looks something like this: > > cdef class MyClass: > cdef void myfunc(self, double *x): > ... (function contents) ... > > def execute(): > call_func( &(self.myfunc) ) > > I'm linking to a function in an external library that accepts a > function pointer of similar signature > > cdef extern from 'somelibrary.h': > cdef void call_func(void (*func)(double *x)) > > However, I receive an error at compile time that a function of type > > void (*)(MyClass, double *) > > cannot be converted to a function of type > > void (*)(double *) > > I was wondering there is a way to unbind this myfunc class method so > that it can be properly sent to this external function.
No you can't, the signatures are incompatible at the C level. > I know that I > can simply create a function pointer attribute as part of the class > but it would seem cleaner for a user to subclass and override myfunc > instead of subclassing and setting the value of function pointer > attribute from within an overridden __cdef__ method. The question is: if the method makes sense without the class, why is it a method in the first place? Maybe you should make it a function and just call it from the class method? Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
