LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type (https://www.linuxquestions.org/questions/programming-9/warning-passing-argument-3-of-%91pthread_create%92-from-incompatible-pointer-type-698319/)

eCli 01-19-2009 06:50 AM

warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
 
Hello there,

I cant understand why this warning: "passing argument 3 of ‘pthread_create’ from incompatible pointer type" occurs, can i get some help plz.Here is my code

Code:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

int globalVariable;

void *stringManager( char *param );

int main( int argc, char *argv[] )
{
        if(argc!=2){

                fprintf(stderr,"usage:a.out<integer value>\n");

                return -1;

        }

        pthread_t tid;
        pthread_attr_t attr;
       
        pthread_attr_init(&attr);

            pthread_create(&tid,&attr,stringManager,argv[1]);

        pthread_join(tid,NULL);
       

        printf("Global variable is : %d\n", globalVariable);

        return 0;
}
void *stringManager( char *param )
{
        int i;
        globalVariable=0;

        for( i=0; i<30; i++ )
        {
                printf("%s\n",param);
                globalVariable = globalVariable + 1;
        }
        pthread_exit(0);
}


Guttorm 01-19-2009 07:44 AM

Hi

Change it to:

void *stringManager( void *param );

This will get rid of the warning. You can then typecast param to char pointer inside the function.


All times are GMT -5. The time now is 06:01 PM.