Closed ghost closed 7 years ago
Which exactly is the error code?
In function ‘main’: p3d.c:163:9: error: cannot convert to a pointer type thpool_addwork(thpool, (void)searchTree, (void_)expandVals);
Have a look at the example at https://github.com/Pithikos/C-Thread-Pool/blob/master/example.c and the tests at https://github.com/Pithikos/C-Thread-Pool/tree/master/tests/src
You need to pass a pointer to void. In your case I assume something like (void*)searchTree
My code is this and I followed the example and passed void pointer to both the function and argument which in my case is a struct . Its just that when i post this comment earlier, it removed * from my code where i have passed the void pointer.So Im posting my code again
struct Tuple { int a; int b; }; void searchTree(struct Tuple exvals)
{ int e1 ,e2; e1 = exvals.a; e2 = exvals.b; .............. } void main(int argc, char *argv[]) { struct Tuple expandVals; expandVals = searchANode(currnode);//another function
thpool = thpool_init(numThreads); thpool_add_work(thpool, (void * )searchTree, (void * )expandVals);
puts("Killing threadpool"); thpool_destroy(thpool); }
Issue resolved ,
my code requires me to pass a struct to task for the threads and i get this error convert to a pointer type
My code is
struct Tuple { int a; int b; }; void searchTree(struct Tuple exvals)
{ int e1 ,e2; e1 = exvals.a; e2 = exvals.b; .............. } void main(int argc, char *argv[]) { struct Tuple expandVals; expandVals = searchANode(currnode);//another function
thpool = thpool_init(numThreads); thpool_addwork(thpool, (void)searchTree, (void_)expandVals);
}