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.