I have a function called by a thread.this function has a unique argument which is queue::my_queue . So I need to perform a cast on void pointer in the method called by the thread as follows:
void *AddPacket(void *Ptr)
{ queue<int> my_queue = (queue*)Ptr ;
my_queue.push(byte) ;
}
and in the main, I do:
int main()
{ // do business
pthread_create(&thread, NULL, &AddPacket, (void*)queue) ;
}
But both conversions are wrong.
the first conversion leads to the error:
request for member ‘push’ in ‘my_queue’, which is of non-class type ‘queue*’
and the second one:
invalid cast from type ‘queue’ to type ‘void*’
How can I solve the problem?
Try:
.. something along those lines, anyway