I am new to Linux programming.
I am returning a value from thread. But when compiled it is listing some errors. I am listing the code and error below. Please help me to understand why the error and how to solve it.
code
#include <pthread.h>
#include <stdio.h>
void* compute_prime (void* arg)
{
int x = 2;
return (void*) x;
}
int main ()
{
pthread_t thread;
int prime;
pthread_create (&thread, NULL, &compute_prime, NULL);
pthread_join (thread, (void*) &prime);
printf("The returned value is %d.\n", prime);
return 0;
}
error
$ g++ -othj pdfex.cpp -lpthread
pdfex.cpp: In function `int main()':
pdfex.cpp:17: error: invalid conversion from `void*' to `void**'
pdfex.cpp:17: error: initializing argument 2 of `int pthread_join(pthread_t, void**)'
What am I doing wrong?