07-18-04 10:55 PM
"googler" <arun_ccjl@yahoo.co.in> wrote in message news:<cddk7o$fqf@odbk17.prod.google.com>.
.
> how to make a class member function as the start function for the
> pthread_create
>
> my code::
>
> class thread
> {
> public :
> void * run( void *);
>
> void start( )
> {
> pthread_t tid;
> pthread_create ( & tid, NULL, &run, NULL );
> }
> };
>
> :The compiler complains that it cannot perform a cast from
> void * (thread::*) (void * ) to void *(*)(void *)
The problem is that the C++ class methods have a hidden argument,
which is the pointer to the structure in the name of which the
function executes ("this"). This is true in case the function is not
static. You could try making run() be static method, and then try
again.
This problem is pretty often, since pthread library is a C interface,
not C++.
Cheers
[ Post a follow-up to this message ]
|