I have a c++ class as below. I am attempting to setup a thread as such below, where my callback (the void pointer function) is within the class. This throws an error on the pthread_create function where it says
cannot convert from type void*(Ball::)(void*) to type void*()(void)
class Ball
{
private: struct BallMsg ballMsg;
private: pthread_t ballThread;
public: Ball(int id)
{
ballMsg.id = id;
ballMsg.r = 7;
ballMsg.x = 60 + (455/2) - 30;
ballMsg.y = 60 + 10 + 5 + ballMsg.r;
ballMsg.c = 0xFFFF0000;
ballMsg.vel = 5.0;
ballMsg.ang = 45.0;
int ret;
ret = pthread_create(&ballThread, NULL, this->ball_thread, NULL);
if (ret !=0)
{
xil_printf("Error launching thread 1\r\n");
}
}
public: void *ball_thread(void *arg)
{
int i = 0;
while(1)
{
//unsigned int tval = sys_time(NULL);
//xil_printf("%d : Time is: %d\r\n", i++, tval);
}
}
public: ~Ball()
{
}
};