_begintread() problem
-
In my previous c program, i use _beginthread(run, 0, NULL) where run is void run(){ } and face no problem. However, when i try to port it to cpp program, i face some problem when my run is defined as void CClass::run(){ } where vs c++ compiler complaint "cannot convert from 'void(void) to 'void(_cdecl*)(void*)' Then I try to cast it by using _beginthread(((_cdecl *)(void *))run, 0, NULL) my vs c++ compiler still complaint that _cdecl is syntax error what should i do to overcome this problem? thank you.
-
In my previous c program, i use _beginthread(run, 0, NULL) where run is void run(){ } and face no problem. However, when i try to port it to cpp program, i face some problem when my run is defined as void CClass::run(){ } where vs c++ compiler complaint "cannot convert from 'void(void) to 'void(_cdecl*)(void*)' Then I try to cast it by using _beginthread(((_cdecl *)(void *))run, 0, NULL) my vs c++ compiler still complaint that _cdecl is syntax error what should i do to overcome this problem? thank you.
Make the function run() a static member of the CClass. Or make it a global function. If you want to execute a member function as thread, it should be either a static member function or a global function.