Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-05-2017, 06:43 AM
|
#1
|
Member
Registered: Mar 2006
Posts: 627
Rep:
|
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?
|
|
|
05-05-2017, 07:20 AM
|
#2
|
Senior Member
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,814
|
Quote:
can anyone advise on what I'm doing wrong please?
|
I'll guess the declaration is wrong/in the wrong place.
|
|
|
05-05-2017, 07:25 AM
|
#3
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,952
|
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.
|
|
1 members found this post helpful.
|
05-05-2017, 07:53 AM
|
#4
|
Member
Registered: Mar 2006
Posts: 627
Original Poster
Rep:
|
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...
|
|
|
05-05-2017, 10:54 AM
|
#5
|
LQ Guru
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 5,026
|
There might be somewhere a declaration of 'TestMovement' that has 'int *' parameter instead of 'void *'
|
|
|
All times are GMT -5. The time now is 04:11 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|