cannot convert '*void(MyClass::*)(void*) to void*(*)(void*) in pthread_create function

后端 未结 3 1683
失恋的感觉
失恋的感觉 2021-01-06 01:34

i\'m trying to create a new thread with a class \"CameraManager\" but i have the following error:

cannot convert \'*void(CameraManager:: * )(void*) to

3条回答
  •  悲哀的现实
    2021-01-06 02:38

    You can't use a pointer to member function as a function pointer unless it's static. You'll have to make dequeueLoop a free function, or write a free function as a wrapper to it.

    To access the class members in a free function, you should have the function pass it's this pointer as the final argument of pthread_create. Then have the free function cast it's argument to a pointer to the class.

提交回复
热议问题