public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
@ 2002-04-07  7:07 Tim Hutt
  2002-04-07 21:16 ` Ye Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Tim Hutt @ 2002-04-07  7:07 UTC (permalink / raw)
  To: pthreads-win32

07/04/02 14:38:30, "XDLai" <xdlai@wmlab.csie.ncu.edu.tw> 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 thread function:

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;

 pBot->OtherMemberFunction();
}



Suggest any better way?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
  2002-04-07  7:07 pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL); Tim Hutt
@ 2002-04-07 21:16 ` Ye Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Ye Liu @ 2002-04-07 21:16 UTC (permalink / raw)
  To: tim.hutt, pthreads-win32

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.

--ye
----- Original Message -----
From: "Tim Hutt" <tim.hutt@btinternet.com>
To: <pthreads-win32@sources.redhat.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" <xdlai@wmlab.csie.ncu.edu.tw> 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
thread function:
>
> 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;
>
>  pBot->OtherMemberFunction();
> }
>
>
>
> Suggest any better way?
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
@ 2002-04-08  1:39 Alexander Terekhov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Terekhov @ 2002-04-08  1:39 UTC (permalink / raw)
  To: pthreads-win32


> How can I get pthread_create to let me specify a c++ memeber function. I
get something like:
>
> Connot convert void*(void*) to void*(__cdecl*)(void*)

http://groups.google.com/groups?as_umsgid=3CAC32F2.A3437CCF%40web.de

Also, see/join "CUJ/"The Boost.Threads Library"
article - feedback/comments?!" comp.programming.threads
discussion; well, I've just recenly posted that message/
call for comments/feedback... so, there is no much of the
"discussion" yet. But, hey, folks, why don't you also join
and share your opinions... with respect to that "boost.org's"
partial/incomplete/buggy-not-fully-complient/poor/etc
*pthreads-win32 "FORK"* (LGPL -> no-restrictions/free
"relaxation" aside)?!?!?!

regards,
alexander.


Tim Hutt <tim.hutt@btinternet.com>@sources.redhat.com on 04/07/2002
03:12:08 PM

Please respond to tim.hutt@btinternet.com

Sent by:    pthreads-win32-owner@sources.redhat.com


To:    pthreads-win32@sources.redhat.com
cc:
Subject:    pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);


How can I get pthread_create to let me specify a c++ memeber function. I
get something like:

Connot convert void*(void*) to void*(__cdecl*)(void*)

Help....






^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
@ 2002-04-07 15:51 Bossom, John
  0 siblings, 0 replies; 5+ messages in thread
From: Bossom, John @ 2002-04-07 15:51 UTC (permalink / raw)
  To: 'tim.hutt@btinternet.com', pthreads-win32

simply have your class have a static member function that you use as the
mainline
instead of a friend class and do the same as your example below.



-----Original Message-----
From: Tim Hutt [mailto:tim.hutt@btinternet.com]
Sent: April 7, 2002 10:08 AM
To: pthreads-win32@sources.redhat.com
Subject: Re: pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);


07/04/02 14:38:30, "XDLai" <xdlai@wmlab.csie.ncu.edu.tw> 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
thread function:

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;

 pBot->OtherMemberFunction();
}



Suggest any better way?

This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so.  Thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL);
@ 2002-04-07  6:11 Tim Hutt
  0 siblings, 0 replies; 5+ messages in thread
From: Tim Hutt @ 2002-04-07  6:11 UTC (permalink / raw)
  To: pthreads-win32

How can I get pthread_create to let me specify a c++ memeber function. I get something like:

Connot convert void*(void*) to void*(__cdecl*)(void*)

Help....


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-04-08  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-07  7:07 pthread_create(&ID, NULL, ***AC++MemberFunction***, NULL); Tim Hutt
2002-04-07 21:16 ` Ye Liu
  -- strict thread matches above, loose matches on Subject: below --
2002-04-08  1:39 Alexander Terekhov
2002-04-07 15:51 Bossom, John
2002-04-07  6:11 Tim Hutt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).