Subj : Re: How to pass class-member function to pthread_create(....)? To : comp.programming.threads From : Vyacheslav Kononenko Date : Fri Jul 15 2005 11:37 am Joe Seigh wrote: > You'll have to use a static function (with external "C" I believe) that > is used as the function parameter for pthread_create. I will have to > invoke the method. The object and other parameterw will have to be passed > by arg. If just object, a simple cast will do, otherwise they have to be > passed in a structure. > > -- > Joe Seigh It has to match signature that "pthread_create" expects so it has to be static method or generic function and extern "C" is not necessary. For example: class foo { void thread_function(); public: static void *static_func( void * ptr) { reinterpret_cast( ptr )->thread_function(); } }; .... foo *test; pthread_create( thread, attr, foo::thread_func, test ); .... Regards, Vyacheslav .