Hi I have problem with CTYPES in python. I have ready dll library with some callback. On swift everything works, but I have some problem in python.
Python:
def set_up_callback(self):
self.lib.set_callback(self.callback1)
@CFUNCTYPE(None, c_float, c_float, c_float, c_uint64)
def callback1( a, b, c, time):
print(a, b, c, time)
c++ declaration of callback
typedef void(*callbackType)(float, float, float, uint64_t, void*);
callbackType callback;
void* context;
c++ init
void setCallback(callbackType callback, void* context) {
this->context = context;
this->callback = callback;
}
c++ induction
callback(1.5f, 2.4f, 1.3f, timestamp, context);
shared.h
extern "C" void SHARED_EXPORT set_callback(callbackType callback, void* context);
and this works good but I would like have self In callback function so I try this
def set_up_callback(self):
callback_type = CFUNCTYPE(None, c_float, c_float, c_float, c_uint64)
callback = callback_type(self.callback1)
self.lib.set_callback(callback)
def callback1(self, a, b, c, time):
print(a, b, c, time)
and with this try I have error Segmentation fault: 11
Thank you in advance for help