The error is that you are converting a function pointer ( void* (*)(void*) ) to an object pointer ( void* ) when pthread_create expects a function pointer for this argument. There is no implicit conversion to undo the tricky conversion you made, hence the error.
The answer is to not do this:
pthread_create(&thread, NULL, &Print_data, NULL);
and you will also need to change Print_data to return void* to match the Posix thread interface:
void *Print_data(void *ptr) { // print stuff return NULL; // or some other return value if appropriate }
As noted in the comments, there are various other problems using this C library directly from C ++; in particular, for portability, the stream input function must be extern "C" . Personally, I would recommend using the standard C ++ thread library (or the Boost implementation if you are stuck with a language version before 2011).
source share