Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8237
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: simple pthread |
| Date | 2011-07-26 19:43 +1200 |
| Message-ID | <9979gdFkjuU14@mid.individual.net> (permalink) |
| References | <0655071f-8f13-4456-af6a-69b80d0a21de@glegroupsg2000goo.googlegroups.com> <j0lmqr$em0$1@dont-email.me> <9adbecbc-a4fa-47d0-a667-040a36f0fd7f@28g2000pry.googlegroups.com> <d7dba757-ed45-4a21-b086-e4b62b363e1d@u6g2000prc.googlegroups.com> |
On 07/26/11 06:53 PM, cerr wrote:
> i have now something like this:
> int MyThread::StartMe(void)
> {
> // starting thread
> pthread_create(&ThreadA, NULL,&PrintMsg, NULL);
>
> }
> //-------------------------------------------------------------
>
> void PrintMsg(void)
> {
> //thread function
> while (1) {
>
> pthread_mutex_lock(&mutex1 );
> count++;
> pthread_mutex_unlock(&mutex1 );
>
> cout<< "I Incremented count: "<< count<< endl;
> }
> }
> but I get following:
>
> $ g++ -pthread -o example example.cpp
> example.cpp: In member function ‘int MyThread::StartMe()’:
> example.cpp:66:49: error: invalid conversion from ‘void (*)()’ to
> ‘void* (*)(void*)’
> example.cpp:66:49: error: initializing argument 3 of ‘int
> pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*),
> void*)’
>
> How do I gwet this compiled? How do I pass a void argument?
> Thank you!
Pass the the correct function type!
extern "C" void* PrintMsg(void*)
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
simple pthread cerr <ron.eggler@gmail.com> - 2011-07-25 20:45 -0700
Re: simple pthread red floyd <no.spam.here@its.invalid> - 2011-07-25 20:55 -0700
Re: simple pthread Ian Collins <ian-news@hotmail.com> - 2011-07-26 15:56 +1200
Re: simple pthread "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-07-26 08:28 +0200
Re: simple pthread cerr <ron.eggler@gmail.com> - 2011-07-25 23:31 -0700
Re: simple pthread cerr <ron.eggler@gmail.com> - 2011-07-25 23:53 -0700
Re: simple pthread Ian Collins <ian-news@hotmail.com> - 2011-07-26 19:43 +1200
Re: simple pthread "io_x" <a@b.c.invalid> - 2011-07-26 09:57 +0200
Re: simple pthread "io_x" <a@b.c.invalid> - 2011-07-26 10:31 +0200
Re: simple pthread "io_x" <a@b.c.invalid> - 2011-07-26 12:38 +0200
Re: simple pthread Ian Collins <ian-news@hotmail.com> - 2011-07-26 22:39 +1200
Re: simple pthread Ian Collins <ian-news@hotmail.com> - 2011-07-26 22:41 +1200
csiph-web