This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
- From: "Ye Liu" <yliu at tibco dot com>
- To: <tim dot hutt at btinternet dot com>, <pthreads-win32 at sources dot redhat dot com>
- Date: Sun, 7 Apr 2002 21:15:50 -0700
- Subject: Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
- References: <E16uDKIfirstname.lastname@example.org>
why the routine of pthread_create should be a static function:
in compilation time, the compiler need an address of the routine, non static
function has no address in the compilation time. i.e., address of automatic
class member function is resolved in run time.
----- Original Message -----
From: "Tim Hutt" <email@example.com>
Sent: Sunday, April 07, 2002 7:07 AM
Subject: Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
> 07/04/02 14:38:30, "XDLai" <firstname.lastname@example.org> wrote:
> >The C++ member function must be a static function.
> But now I cant call non-static member function of the same class from the
> c:\t\cpp\killbot\bot.cpp(124) : error C2352: 'CBot::Connect' : illegal
call of non-static member function
> c:\t\cpp\killbot\bot.h(32) : see declaration of 'Connect'
> I managed to get it to work another way by having it as a global friend
function of the class, and passing a pointer to the class as the paramater:
> CBot class
> friend void* Main(void* pData);
> bool OtherMemberFunction();
> void* Main(void* pData)
> CBot* pBot = (CBot*)pData;
> Suggest any better way?