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

Hi,

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 *){

printf("calling\n");
}



XCode gives me this error:

template.mm:859: error: argument of type 'void (MyClass:Smile(void*)' does not match 'void (*)(void*)'




Thanks in advance,
-joshua
avatar
meteors

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:

Code:

class MyClass
{
public:
SIO2timercallback *_SIO2timercallback;


}


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

Code:

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);
avatar
sio2interactive

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

View user profile http://sio2interactive.com

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