0
我传递int类型在pthread_create的数组,并收到错误:ç并行线程传递int类型的数组
histogram.c:138:3: warning: passing argument 3 of
‘pthread_create’ from incompatible pointer type [enabled by default]
expected ‘void * (*)(void *)’ but argument is of type ‘void * (*)(int *)’
void *output_results();
pthread_create(&t2, NULL, output_results, (void *)bins);
void *output_results(int *bins) {
some code
}
没想到,为什么没有在pthread_create中投射? –
您正在投射'pthread_create'的第四个参数,而问题是关于第三个:函数指针。 'pthread_create'的原型需要第三个参数是'void *(*)(void *)'类型。 – Simon