How do I create a thread routine of a static member function
class Blah
{
static void WINAPI Start();
};
// ..
// ...
// ....
hThread = (HANDLE)_beginthre
Sometimes, it is useful to read the error you're getting.
cannot convert parameter 3 from 'void (void)' to 'unsigned int (__stdcall *)(void *)'
Let's look at what it says. For parameter three, you give it a function with the signature void(void)
, that is, a function which takes no arguments, and returns nothing. It fails to convert this to unsigned int (__stdcall *)(void *)
, which is what _beginthreadex
expects:
It expects a function which:
unsigned int
:stdcall
calling conventionvoid*
argument.So my suggestion would be "give it a function with the signature it's asking for".
class Blah
{
static unsigned int __stdcall Start(void*);
};