This is the mail archive of the
mailing list for the pthreas-win32 project.
Using a class method as starting routine.
- To: pthreads-win32 at sourceware dot cygnus dot com, pthreads-win32-info at sourceware dot cygnus dot com
- Subject: Using a class method as starting routine.
- From: "Ye Liu" <yliu at tibco dot com>
- Date: Mon, 30 Jul 2001 13:46:13 -0700
- Organization: Tibco Software
A rather dump question: how to use a class method as a starting routine
I have the following code:
/* create.h */
void *thread_routine(void *arg);
/* create.cpp */
void *create::thread_routine(void *arg)
printf("The thread is here\n");
pthread_create(&thread_id, &thread_attr, create::thread_routine, NULL);
When I compiled it using VC6.0 (win32-pthread library of course), I got
C:\ye\work\vs\pthread_projects\create\create.cpp(14) : error C2664:
'pthread_create' : cannot convert parameter 3 from 'void *(void *)' to
'void *(__cdecl *)(void *)'
None of the functions with this name in scope match the target
Error executing cl.exe.
It seems that the compiler does not recognize thread_routine as a
address. Why does it happen? How to get around of it?
Thanks a lot!