c pthread passing array of type int

前端 未结 2 1644
后悔当初
后悔当初 2021-01-24 23:00

I am passing an array of type int pthread_create and getting error:

  histogram.c:138:3: warning: passing argument 3 of
 ‘pthread_create’ from incompatible   poi         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-24 23:34

    Should be

    void *output_results(void*);
    pthread_create(&t2, NULL, output_results, (void *)bins);
    
    void *output_results(void *data) {
        int *bins = (int*)data;
        // some code
    }
    

    The error message is pretty clear: the function should be of type void * (*)(void *) and not void * (*)(int *) (plus your prototype for output_results was not matching its definition).

提交回复
热议问题