IdleTimers and NewEventLoopTimerUPP

For some reason, I keep getting this error when my IdleTimer is inside my Application class:
function call ‘[Aspire].NewEventLoopTimerUPP(void)’ does not match NewEventLoopTimerUPP(pascal void(*)(OpaqueEventLoopTimerRef , void))’

Now basically it’s telling me that the IdleTimer I’m supplying to NewEventLoopTimerUPP is wrong… but I see nothing wrong with it. It is declared in my class Aspire(the application class) as:
class Aspire

pascal void GameIdleTimer(EventLoopTimerRef inTimer, void* userData);


It is used in the function Aspire::Setup like this:
EventLoopTimerUPP sTimerUPP = NewEventLoopTimerUPP (GameIdleTimer);

ANy idea what is going on?

It’s a member function. It needs to be static.

Member functions have an implicit first parameter – “this”.

In order to work this, you’re going to need to make your function static, and pass the this pointer in the userData.


Since my IdleTimer contains a member function : DoUpdate(), will I need to make DoUpdate static as well? Or how would I write my IdleTimer then, since userData->DoUpdate(); doesn’t work

If you want the timer to call an instance method, you can do something like this, passing the address of an object of type Foo as the userData parameter to InstallEventLoopTimer.

If you want it to call a static function, that’s fine too.

class Foo
static pascal void IdleTimer(EventLoopTimerRef timer, void* userData)

void DoTimer(EventLoopTimerRef timer)


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.