[407] in Pthreads mailing list archive
Re: proven's pthread with C++?
daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed Sep 11 00:46:38 1996
To: "Alex H.K. Wong" <wong@CS.UCLA.EDU>
Cc: pthreads@MIT.EDU
In-Reply-To: Your message of "Tue, 10 Sep 1996 21:07:21 PDT."
<Pine.SOL.3.91.960910210005.375A-100000@flamingo.cs.ucla.edu>
Date: Wed, 11 Sep 1996 00:38:53 EDT
From: Greg Hudson <ghudson@MIT.EDU>
> Any idea of what I should really pass in start() here?
The third argument to pthread_create() must be a function which
accepts a void * and returns a void *. It cannot be a class member
function.
When you pass "this" as the datum argument, you get lucky with some
C++ compilers because class member functions are often implemented as
C functions with a first argument giving the object. This is not
safe.
> A.C: In method `void A::start()':
> A.C: warning: ANSI C++ forbids implicit conversion from `void *' in argument
> passing
You're getting this warning because the type of the third argument to
pthread_create() is void *(*)(void *) and you passed in a void *.
Giving the name of a function with the correct type, without a cast,
will get rid of the warning.
(You don't need a cast on the fourth argument, incidentally; implicit
casts to void * are fine.)