LinuxQuestions.org
Register a domain and help support LQ
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 Search this Thread
Old 01-19-2009, 07:50 AM   #1
eCli
LQ Newbie
 
Registered: Jan 2009
Posts: 1
Thanked: 0
warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type


[Log in to get rid of this advertisement]
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);
}
eCli is offline     Reply With Quote
Old 01-19-2009, 08:44 AM   #2
Guttorm
Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 616
Thanked: 39
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.
Guttorm is offline     Reply With Quote

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


All times are GMT -5. The time now is 06:29 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.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.
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