Setting a timer callback within a class

View previous topic View next topic Go down

Setting a timer callback within a class

Post  meteors on Sat Jan 03, 2009 2:07 pm


I have emebdded an SIO2timer inside a class. I'm using this code in my class constructor:

sio2TimerCreate(wobble_timer, sio2->_SIO2window, wobble, WOBBLE_TIMER_INCREMENT);

Then I have the callback defined as:

void MyClass::wobble(void *){


XCode gives me this error: error: argument of type 'void (MyClass:Smile(void*)' does not match 'void (*)(void*)'

Thanks in advance,

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

View user profile

Back to top Go down

Re: Setting a timer callback within a class

Post  sio2interactive on Sat Jan 03, 2009 4:27 pm

I think that the error message that XCode give you is pretty self explanatory... Wink your function have to fit the following type: typedef void( SIO2timercallback( void * ) );

If you want to put this in a class you should do something like this:


class MyClass
SIO2timercallback *_SIO2timercallback;


Then assign a void function( void * ) to it...


void wobble( void *_ptr )


_SIO2timercallback = wobble;
sio2TimerCreate(wobble_timer, sio2->_SIO2window, myobject->_SIO2timercallback, WOBBLE_TIMER_INCREMENT);

or directly:

sio2TimerCreate(wobble_timer, sio2->_SIO2window, mobble, WOBBLE_TIMER_INCREMENT);

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum