|
From: Andreas J. <and...@gm...> - 2026-08-07 04:59:42
|
Hi,
I'm Andy and new to the USB world. So, I'm trying my first baby steps
and just stumbled over a problem that I cannot solve:
I want to create a context like this:
int res = libusb_init_context ( &ctx, opts, optionsLength );
Obviously I need options:
int optionsLength = 3;
struct libusb_init_option opts[optionsLength];
I can set most options successfully but not the one that takes a
callback function:
void my_log_callback ( libusb_context *ctx, enum libusb_log_level
level, const char *str )
opts[2] = ( struct libusb_init_option ) {
LIBUSB_OPTION_LOG_CB, { my_log_callback }
};
This fails with:
error: invalid conversion from ‘void (*)(libusb_context*,
libusb_log_level, const char*)’ to ‘int’ [-fpermissive]
I tried a function pointer:
void ( *cbPtr ) ( libusb_context*, enum libusb_log_level, const
char* ) = my_log_callback;
And:
libusb_log_cb cb = cbPtr;
All with similar results. I'm using libusb 1.0.30 with C++.
What am I doing wrong? How do I properly pass on that function?
|