I am trying to pass a pointer to a function, but I keep getting a compiler error. I usually do not pass function pointers, but this requires it. I think you only need to see the ads to see what I am doing wrong.
in the header file that I have:
pthread_t * createThread(void *(*func)(void *), string arg)
and in implementation it’s the same thing:
pthread_t * createThread(void *(*func)(void *), string arg)
In the call to this function, I do: createThread (& afunction, "run again")
And function declaration:
void *afunction(void *ptr) //(no header, same for both declaration and implementation).
but the compiler spits it out:
Undefined symbols for architecture x86_64:
"createThread(void* (*)(void*), std::basic_string<char, std::char_traits<char>, std::allocator<char> >)", referenced from:
spawnSingleThreadTest() in threadTests.o
source
share