FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Setting a timer callback within a class

2 posters

Go down

Setting a timer callback within a class Empty Setting a timer callback within a class

Post  meteors 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
meteors
meteors

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

Back to top Go down

Setting a timer callback within a class Empty Re: Setting a timer callback within a class

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

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

http://sio2interactive.com

Back to top Go down

Back to top

- Similar topics

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