LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 05-05-2017, 06:43 AM   #1
knobby67
Member
 
Registered: Mar 2006
Posts: 622

Rep: Reputation: 42
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?
 
Old 05-05-2017, 07:20 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,571

Rep: Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874Reputation: 1874
Quote:
can anyone advise on what I'm doing wrong please?
I'll guess the declaration is wrong/in the wrong place.
 
Old 05-05-2017, 07:25 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,696
Blog Entries: 13

Rep: Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914Reputation: 3914
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.
Old 05-05-2017, 07:53 AM   #4
knobby67
Member
 
Registered: Mar 2006
Posts: 622

Original Poster
Rep: Reputation: 42
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...
 
Old 05-05-2017, 10:54 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,050

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Failing to compile wireshark, conversion from ‘void *’ to ‘iface_mon_cb’ error cheese1343 Linux - Software 6 04-08-2013 03:37 AM
(void)time(&cur_time); Why did the author put (void) here? e3399 Programming 3 03-28-2011 11:45 AM
error: invalid conversion from `void*' to `char*' pstevens57 Programming 2 03-10-2009 01:57 PM
int * function(void)??? kalleanka Programming 5 08-01-2006 09:37 AM
error: invalid conversion from `void*' to `char**', where should I start to look for RHLinuxGUY Programming 4 05-20-2006 08:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration