I just tried to use boost::bind to create a function pointer from an object method to define it as a Motif callback function:
class AnimationController { public: void timerCB( XtPointer, XtIntervalId* ); void startTimer() { this->mTimeout = XtAppAddTimeOut( this->mAppContext, ANIMATION_TIMESTEP, boost::bind( &AnimationController::timerCB, this ), NULL ); } ... };
For the definition of the Motif function: XtIntervalId XtAppAddTimeOut( XtAppContext /* app_context */, unsigned long /* interval */, XtTimerCallbackProc /* proc */, XtPointer /* closure */ );
with
typedef void (*XtTimerCallbackProc)( XtPointer /* closure */, XtIntervalId* /* id */ );
But I get the following error:
../AnimationController.cpp: In member function 'void geo::AnimationController::startTimer()': ../AnimationController.cpp:193: error: cannot convert 'boost::_bi::bind_t<void (&)(void*, XtIntervalId*), boost::_mfi::dm<void ()(void*, XtIntervalId*), geo::AnimationController>, boost::_bi::list1<boost::_bi::value<geo::AnimationController*> > >' to 'void (*)(void*, XtIntervalId*)' for argument '3' to 'XtIntervalId XtAppAddTimeOut(_XtAppStruct*, long unsigned int, void (*)(void*, XtIntervalId*), void*)'
Bind creates a function object, while XtAppAddTimeOut expects a function pointer, as you mentioned. You can define a static member function that matches XtTimerCallbackProc signature, and pass it without bind.