_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 CClass. Or make it a global function. The problem will be solved
-
Make the function run() a static member of CClass. Or make it a global function. The problem will be solved
... and also use _beginthreadex() instead of _beginthread(). It may save you from big headaches. I vote pro drink :beer:
-
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.
Your question is answered in the VC forum FAQ. --Mike-- http://home.inreach.com/mdunn/ You are the weakest link, GOODBYE!