Function call missing argument list to create pointer

You cannot directly call a non-static class method using this callback. This is because the method is expecting to be called with the class this pointer.

If you don’t need any data from your class, then just make the method static. If you do need data from the class, you can make a static “stub” that takes the class pointer in the userData parameter and then calls the original method. Something like:

Declaration:

static void VRPN_CALLBACK handle_analog_stub( void* userData, const vrpn_ANALOGCB a );

Definition

void VRPN_CALLBACK MainWindow::handle_analog_stub( void* userData, const vrpn_ANALOGCB a )
{
   MainWindow *mainWindow = static_cast<MainWindow*>(userData);
   mainWindow->handle_analog(NULL, a);
}

Then when you call the function use:

vrpnAnalog->register_change_handler( this, handle_analog_stub );

(Updated to static_cast to pointer, thanks rpavlik)

Leave a Comment