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