LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-25-2003, 01:54 AM   #1
c12ayon
LQ Newbie
 
Registered: Oct 2003
Posts: 28

Rep: Reputation: 15
so confusing


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

void printMsg(void);

int main(){
pthread_t accnt1, accnt2;
pthread_create(accnt1, NULL, printMsg(), );
return 0;
}
void printMsg(){
printf("Hello PThread\n");
}

it shows:
tes.c: In function `main':
tes.c:8: error: syntax error before ')' token

is it the rite way to use pthread_create?
 
Old 10-25-2003, 02:42 AM   #2
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Don't know much about it but that comma doesn't look right


pthread_create(accnt1, NULL, printMsg(), );
 
Old 10-26-2003, 04:11 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
That's how pthread_create call should look like:
int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *(*start_routine)(void *), void * arg);

So, in your case, it should be:
pthread_create(accnt1, NULL, printMsg(),NULL );

BTW It's a good idea to check if pthread_create ends with a success.
 
Old 10-26-2003, 04:14 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
you dont put the brackets printMsg(), it should be:
pthread_create(accnt1, NULL, printMsg, NULL); and optionally to make gcc stfu
pthread_create(accnt1, NULL, (void *)printMsg, NULL);
 
Old 10-26-2003, 04:18 PM   #5
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You're right infamous41md, I was copying.
 
Old 10-27-2003, 12:52 AM   #6
c12ayon
LQ Newbie
 
Registered: Oct 2003
Posts: 28

Original Poster
Rep: Reputation: 15
thx guys...
 
  


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
mplayer confusing me subh Debian 6 11-30-2005 04:29 PM
What is confusing my Intel536ep? bobzilla Debian 1 11-24-2005 08:34 PM
Confusing useradd Arenba Linux - Newbie 3 09-23-2003 07:22 AM
Confusing the squid 80s Linux - Networking 1 08-20-2003 03:02 PM
Very confusing rm Luc Linux - Newbie 3 11-04-2002 02:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration