Exforsys

Online Training

pthread.h please help

This is a discussion on pthread.h please help within the Software Patterns forums, part of the Testing category; I am trying to spawn a thread that is a member function: pthread_create(&thread, NULL, (void*)&CLASSNAME::functionname, ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-17-2003, 01:44 PM
sportvette
Guest
 
Posts: n/a
pthread.h please help

I am trying to spawn a thread that is a member function:

pthread_create(&thread, NULL, (void*)&CLASSNAME::functionname, NULL);

I am getting this error message:
converting from 'void (CLASSNAME::*)()' to 'void *'
ANSI C++ forbids implicit conversion from 'void*' in argument passing

any help would be appreciated.

Thanks,
Mark Fleureton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-17-2003, 04:57 PM
Artie Gold
Guest
 
Posts: n/a
Re: pthread.h please help

sportvette wrote:
> I am trying to spawn a thread that is a member function:


You can't. At least not directly.
Member functions and regular functions are different, incompatible
creatures.
Member functions operate on an object; where (oh where) is this object
supposed to come from?

>
> pthread_create(&thread, NULL, (void*)&CLASSNAME::functionname, NULL);
>
> I am getting this error message:
> converting from 'void (CLASSNAME::*)()' to 'void *'
> ANSI C++ forbids implicit conversion from 'void*' in argument passing


OK. You're trying a cast (one which makes no sense on its face) -- and
you're even casting to the WRONG TYPE!

[have you even looked at the prototype for pthread_create()?]

What you need to do is write a wrapper with "C" linkage to pass to
pthread_create().

BTW - WTF are you asking this here? More significantly, this comes up on
news:comp.programming.threads (where this question would belong if it
hadn't been asked and answered countless times already) every week or
so. Have you bothered to look (or lurk) there?

--ag

--
Artie Gold -- Austin, Texas

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:07 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.