I have problems using pthread_create if passing a class method to an argument, because the compiler constantly produces an error:
cannot convert 'void* (Server::*)(void*)' to 'void* (*)(void*)' for argument '3' to 'int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)' Server.cpp I have a Server class, it has a private member pthread_t receivingThread_; the public function void myFunc1() and another public function void* myFunc2(void *args) which returns 0.
Here is the function description, where I make the call to pthread_create ()
myFunc1(){ pthread_create(&receivingThread_,NULL,&Server::myFunc2,NULL); } However, it does not work, most likely somewhere is a common mistake, but after reading other questions, I cannot understand how to fix my own. Thanks in advance for your help.
thisparameter. Even if you type types, pthread_create cannot pass this this to it. maybe a static method could be used. For now, I only see a crutch from the usual function outside the class - Mike