LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
Thread Tools
Old 05-27-2005, 12:01 PM   #1
wallwaters
LQ Newbie
 
Registered: May 2005
Posts: 6
Thanked: 0
passing arg 3 of `pthread_create' from incompatible pointer type


[Log in to get rid of this advertisement]
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
wallwaters is offline     Reply With Quote
Old 05-27-2005, 12:47 PM   #2
freegianghu
Member
 
Registered: Oct 2004
Location: somewhere in the street
Distribution: Window$
Posts: 192
Thanked: 0
Re: passing arg 3 of `pthread_create' from incompatible pointer type

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); // change to 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) // change to 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
freegianghu is offline     Reply With Quote
Old 06-02-2005, 04:23 PM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,969
Thanked: 19
Re: Re: passing arg 3 of `pthread_create' from incompatible pointer type

freegianghu, you can't return NULL; from a function with a void return-type.

The problem is that sendThread is defined both as a function (by a forward declaration) and as a variable. The variable masks the definition of the function, and so both sendThread arguments passed to pthread_create are of type pthread_t.

Since the third argument to pthread_create is supposed to be a callback function, not a pthread_t, this won't compile.
rjlee is offline     Reply With Quote
Old 06-02-2005, 09:58 PM   #4
freegianghu
Member
 
Registered: Oct 2004
Location: somewhere in the street
Distribution: Window$
Posts: 192
Thanked: 0
Re: Re: Re: passing arg 3 of `pthread_create' from incompatible pointer type

Quote:
Originally posted by rjlee
freegianghu, you can't return NULL; from a function with a void return-type.

The problem is that sendThread is defined both as a function (by a forward declaration) and as a variable. The variable masks the definition of the function, and so both sendThread arguments passed to pthread_create are of type pthread_t.

Since the third argument to pthread_create is supposed to be a callback function, not a pthread_t, this won't compile.
Sorry, I made a mistake . Its should be void *sendThread(void *rxLength)

Have a nice day,
Giang Hu
freegianghu is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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


All times are GMT -5. The time now is 03:36 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration