attaching callback inside a class's member function

I tried to attach a callback inside a member function, it says the callback
function has to be static, but if i change to static, none of the variables
can be accessed from that static function… codes are as following:

void RtProgressWidgetType :: Initialize(PtWidget_t* ParentWidget)
{
PtSetArg(&args[0], Pt_ARG_TIMER_INITIAL, 500, 0);
PtSetArg(&args[1], Pt_ARG_TIMER_REPEAT, 100, 0);
Timer = PtCreateWidget(PtTimer, ParentWidget, 2, args);
PtAddCallback(Timer, Pt_CB_TIMER_ACTIVATE, (PtCallbackF_t*)Timer_Repeat_CB,
NULL);
PtRealizeWidget(Timer);
}

ran zhang <rzhang@vamcointernational.com> wrote:

I tried to attach a callback inside a member function, it says the callback
function has to be static, but if i change to static, none of the variables
can be accessed from that static function… codes are as following:

Callback’s must be made static (ie. there can only be one instance) otherwise
the calling code (calling the call-back) would have to traverse the vtable each
time to find the member functions location.

-Adam

Then how can I access the class’s variables in a static call back function??

Operating System for Tech Supp <os@qnx.com> wrote in message
news:9qfc1t$8s4$1@nntp.qnx.com

ran zhang <> rzhang@vamcointernational.com> > wrote:
I tried to attach a callback inside a member function, it says the
callback
function has to be static, but if i change to static, none of the
variables
can be accessed from that static function… codes are as following:


Callback’s must be made static (ie. there can only be one instance)
otherwise
the calling code (calling the call-back) would have to traverse the vtable
each
time to find the member functions location.

-Adam

Pass the this pointer as part of the callback data?

ran zhang <rzhang@vamcointernational.com> wrote:

Then how can I access the class’s variables in a static call back function??

Operating System for Tech Supp <> os@qnx.com> > wrote in message
news:9qfc1t$8s4$> 1@nntp.qnx.com> …
ran zhang <> rzhang@vamcointernational.com> > wrote:
I tried to attach a callback inside a member function, it says the
callback
function has to be static, but if i change to static, none of the
variables
can be accessed from that static function… codes are as following:


Callback’s must be made static (ie. there can only be one instance)
otherwise
the calling code (calling the call-back) would have to traverse the vtable
each
time to find the member functions location.

-Adam


cburgess@qnx.com

Hand this pointer into callback.

ran zhang wrote:

Then how can I access the class’s variables in a static call back function??

Operating System for Tech Supp <> os@qnx.com> > wrote in message
news:9qfc1t$8s4$> 1@nntp.qnx.com> …
ran zhang <> rzhang@vamcointernational.com> > wrote:
I tried to attach a callback inside a member function, it says the
callback
function has to be static, but if i change to static, none of the
variables
can be accessed from that static function… codes are as following:


Callback’s must be made static (ie. there can only be one instance)
otherwise
the calling code (calling the call-back) would have to traverse the vtable
each
time to find the member functions location.

-Adam

can u show me how to fix in code?

my code is:

PtAddCallback(Timer, Pt_CB_TIMER_ACTIVATE, (PtCallbackF_t*)Timer_Repeat_CB,
NULL);

then, the call back declaration is:

static void RtProgressWidgetType :: Timer_Repeat_CB()
{
}


Dean Douthat <ddouthat@faac.com> wrote in message news:3BCB43C8.91C9DBF2@faac.com

Hand this pointer into callback.

ran zhang wrote:

Then how can I access the class’s variables in a static call back function??

Operating System for Tech Supp <> os@qnx.com> > wrote in message
news:9qfc1t$8s4$> 1@nntp.qnx.com> …
ran zhang <> rzhang@vamcointernational.com> > wrote:
I tried to attach a callback inside a member function, it says the
callback
function has to be static, but if i change to static, none of the
variables
can be accessed from that static function… codes are as following:


Callback’s must be made static (ie. there can only be one instance)
otherwise
the calling code (calling the call-back) would have to traverse the vtable
each
time to find the member functions location.

-Adam