LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   pthread giving error: invalid conversion from ‘void* (*)(int*)’ to ‘void* (*)(void*)’ (https://www.linuxquestions.org/questions/programming-9/pthread-giving-error-invalid-conversion-from-%91void%2A-%2A-int%2A-%92-to-%91void%2A-%2A-void%2A-%92-4175605304/)

knobby67 05-05-2017 06:43 AM

pthread giving error: invalid conversion from ‘void* (*)(int*)’ to ‘void* (*)(void*)’
 
Hi All,
I just went to update some old code using pthreads and get the above error.The code did work in the past. I call the thread with
Code:

pthread_create( &Test_Thread, NULL, &TestMovement, ( void * )amount );
and the function is
Code:

void *TestMovement( void *data )
can anyone advise on what I'm doing wrong please?

ntubski 05-05-2017 07:20 AM

Quote:

can anyone advise on what I'm doing wrong please?
I'll guess the declaration is wrong/in the wrong place.

rtmistler 05-05-2017 07:25 AM

No expert on it, I've used them and each time I do so, I look it up somewhere. This example seems very fundamental and there do seem to be some minor differences between their example and the minor amount of code you've shown.

http://timmurphy.org/2010/05/04/pthr...rking-example/

Suggest if you still have difficulties, that you post enough additional code so that we can see how you've declared Test_Thread and how you've coded TestMovement.

knobby67 05-05-2017 07:53 AM

Thanks that link demo fixed it, now what's even odder is some other threads in the same file are declared in exactly the same way ( my original way ) and they work...

NevemTeve 05-05-2017 10:54 AM

There might be somewhere a declaration of 'TestMovement' that has 'int *' parameter instead of 'void *'


All times are GMT -5. The time now is 05:21 AM.