This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> I would like to use a C++ class member function as the starting point for a > thread. When I try to do > MyClass *object; > pthread_create(&id,NULL,object->member,NULL); > I get syntax errors about converting from (MyClass::*) to void*. Is there a > clean way to do this with g++? Going back to the original topic of the thread (no pun intended here), I (may be wrong in this) thought that the following would work: class A { public: void *threadfunc(); }; typedef void *(*threadfunc_t)(void *); int func(void) { A a; : : pthread_create(&id, NULL, (threadfunc_t)(a->threadfunc), &a); : : } I haven't even entered the code above into an editor nor come close to compiling it, but as I the instance pointer (iirc) was passed to a non-static member function as an implicit (first) parameter, my thoughts were that the above *should* work (with a little tweaking, perhaps)? I could be totally wrong on several issues, but that was my understanding of things. Mo. -- | Ekto - The Collective | "Resistance is futile" | | http://www.ekto.org/ | ekto@ekto.org | -------------------------------------------------------------------
S/MIME Cryptographic Signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |