I have code that makes a bunch of threads, and assigns them a function.
file a.c:
#include "b.h"
int main()
{
pthread_t tids[n];
void * (*func) (void*);
func = function_thread; \\this is the process from another function
//more code
for(int i = 0; i < n; i++){
pthread_create(&tids[i], NULL, func, (void*)i));
}
}
file b.c:
void * function_thread(void * i)
{
//do stuff
pthread_exit(NULL);
}
Is there anything special I need to do to make this work?
I ask, because right now I'm getting something like the following when I try to make this. Am I on the right track, or is this error caused by something else entirely?
/tmp/ccAiAxMg.o: In function `main':
a.c:(.text+0x4f8): undefined reference to `function_thread'
I know the b.h file is linked just fine, because I'm using structs in it without any complaints from the compiler.