error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ - pthreads

后端 未结 4 592
我在风中等你
我在风中等你 2021-02-14 15:30
anisha@linux-y3pi:~> g++ conditionVarTEST.cpp -Wall

conditionVarTEST.cpp: In function ‘int main()’:
conditionVarTEST.cpp:33:53: error: invalid conversion from ‘void*         


        
4条回答
  •  别跟我提以往
    2021-02-14 15:59

    If you look at the manual page you will see that the function argument is

    void *(*start_routine) (void *)
    

    That is, a pointer to a function which takes one void * argument and returns void *.

    To get rid of your errors, change your function to return void *, and pass it without type-casting it. The return from the thread function can be a simple return NULL if you don't care about the value.

提交回复
热议问题