c++ - pthread with without static member function -
i have classb have thread object , function defined as:
pthread_t m_thworkthread; void* threadproc(void *);
and in constructor of classb, create thread like:
pthread_create(&m_thworkthread, null, &(classb::threadproc), this);
however got 2 error messages:
error: iso c++ forbids taking address of unqualified or parenthesized non-static member function form pointer member function.
cannot convert âvoid* (classb::)(void)â âvoid* ()(void)â argument â3â âint pthread_create(pthread_t*, const pthread_attr_t*, void* ()(void), void*)â pthread_create(&m_thworkthread, null, &(classb::threadproc), this);
however if define function static, not complain:
static void* threadproc(void *);
however not want static, since create multiple threads , want each thread has separate threadproc function.
Comments
Post a Comment