c++ - How to pass a member function as pthread start_routine? -
i got that:
void* xxx::yyy(void* threadidptr)
and that:
pthread_create( &tp, null, xxx::yyy, (void*) &i);
but compile error:
error: argument of type 'void* (xxx::)(void*)' not match 'void* (*)(void*)'
how pass correctly?
a pointer member function not pointer function. 2 aren't same. trying use pointer member function if pointer function...well, best hope crash , cleanly.
although it's not technically defined behavior, there's @ least reasonable chance can use pointer static member function. can pass pointer object parameter, , can invoke proper member function of object.
other that, can use normal function pthreads expects, , done it.
Comments
Post a Comment