LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Closed Thread
 
Search this Thread
Old 05-27-2005, 10:56 AM   #1
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 9

Rep: Reputation: 0
What is the warning: passing arg 3 of `pthread_create' from incompatible pointer type


passing arg 3 of `pthread_create' from incompatible pointer type

I do not understand this warning.


Following is my code . what is that warning. I dont see any thing wrong in code. Please help me.


Result vSend(int rxLength);
void *sendThread(void *rxLength);

void main()
{
vSend(100);
}
Result vSend(int rxLength)
{
Result status = PENDING;
pthread_t sendThread;
int tRetVal;
App_Report("vSend %d",rxLength);
tRetVal = pthread_create( &sendThread, NULL, &sendThread, &rxLength);
return status;
}


void *sendThread(void *rxLength)
{
int *length = (int *) rxLength;
print("Length %d"length );
return NULL;
}


passing arg 3 of `pthread_create' from incompatible pointer type

Thanks
Suneel
 
Old 05-29-2005, 05:30 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
Re: What is the warning: passing arg 3 of `pthread_create' from incompatible pointer

Quote:
Originally posted by wallwaters
passing arg 3 of `pthread_create' from incompatible pointer type

I do not understand this warning.


Following is my code . what is that warning. I dont see any thing wrong in code. Please help me.


Result vSend(int rxLength);
void *sendThread(void *rxLength);

void main()
{
vSend(100);
}
Result vSend(int rxLength)
{
Result status = PENDING;
pthread_t sendThread;
int tRetVal;
App_Report("vSend %d",rxLength);
tRetVal = pthread_create( &sendThread, NULL, &sendThread, &rxLength);
return status;
}


void *sendThread(void *rxLength)
{
int *length = (int *) rxLength;
print("Length %d"length );
return NULL;
}


passing arg 3 of `pthread_create' from incompatible pointer type

Thanks
Suneel

Firstly, the return type of main is always int, never void. (But as a special case, you don't have to specify a return value for main; 0 is assumed if you don't).

Secondly, you're missing the definition of pthread_create. I'll just assume that you're using the pthread library and forgot to include the #include statements in the post.

The sendThread function isn't used; you've defined a variable of type pthread_t in the main function which masks the declaration and usage of the sendThread function. You're not setting the value of this variable either, and pthread_create will attempt to call this, so you'll get a crash just as soon as it tries to do this (if you're lucky).

The reason for the error is that the pthread_t type (type of the value you're passing) is defined in the header as type unsigned long int (and you're passing it as a pointer to unsigned long) while the pthread_create function expects as its third argument a pointer to a function taking a void pointer and returning a void pointer.

Last edited by rjlee; 05-29-2005 at 05:31 AM.
 
Old 05-30-2005, 03:45 PM   #3
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Problem solved

tRetVal = pthread_create( &sendThread, NULL, &sendThread, &rxLength);


This is my mistake

I used same sendThread as function name and the Id of the thread it was my mistake.
Thank you very much for your responce.
 
Old 06-01-2005, 08:30 AM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

Continue this discussion here
 
  


Closed Thread


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
passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Programming 8 03-08-2010 01:46 AM
Passing arg 3 of blah makes pointer from integer without a cast xconspirisist Programming 6 08-22-2004 08:04 AM
How does one surpress incompatible pointer type warnings? tonyfreeman Programming 1 08-18-2004 06:06 PM
Getting an incompatible pointer type error... JStew Programming 4 03-06-2003 05:08 PM
Installing Wine - incompatible pointer type orange400 Linux - Software 1 03-03-2003 12:57 AM


All times are GMT -5. The time now is 11:27 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration