I've been using the pthreadpool implementation here in some previous C code that I wrote, and it's been great. Now I want to use it in a C++ project, but I'm having some issues. Here is how I normally set it up in C:
void MY_FUNCTION()
{
struct pool* p = pool_start((void*)theJob, NUM_THREADS);
for (int a = 0; a < jobCount; a++)
{
arguments_t* args = calloc(1, sizeof(*args));
//assign values to args
pool_enqueue(p, args, true);
}
pool_wait(p);
pool_end(p);
}
void theJob(arguments_t* args)
{
//do stuff
}
Now if I try this in C++ (Visual Studio) I get the error argument of type "void *" is incompatible with parameter of type "void *(*)(void *)". Well, I tried doing
struct pool* p = pool_start((void* (*)(void*))theJob, NUM_THREADS);
and it stopped complaining. When I run the code though, I get the error LNK2019 unresolved external symbol "void * __cdecl pool_start(void * (__cdecl*)(void *),unsigned int)" (?pool_start@@YAPEAXP6APEAXPEAX@ZI@Z) referenced in function "void __cdecl MY_FUNCTION()" (?MY_FUNCTION@@YAXH_K0@Z).
Can anyone tell me what I'm supposed to do here? This isn't really a matter of "unresolved external symbol" but untangling what void *(*)(void *) means and how to properly give pool_start() what it needs.