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
 
Search this Thread
Old 01-19-2009, 06:50 AM   #1
eCli
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
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);
}
 
Old 01-19-2009, 07:44 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,148

Rep: Reputation: 236Reputation: 236Reputation: 236
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.
 
  


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
passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Programming 8 03-08-2010 01:46 AM
warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast nasim751 Programming 2 02-10-2008 10:47 PM
warning: passing argument 2 of ‘memset’ makes integer from pointer without a cast nasim751 Programming 3 01-30-2008 09:16 AM
What is the warning: passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Linux - Software 3 06-01-2005 08:30 AM
passing function pointer as argument worldmagic Programming 7 08-04-2004 03:33 PM


All times are GMT -5. The time now is 08:00 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