I've got this header:
class jmmvAsync
{
public:
static void run(LPCTSTR msg);
};
and this .cpp
void jmmvAsync::run(LPCTSTR msg){
MessageBox(NULL, msg, NULL, NULL);
}
And I'm calling a this function:
LPTCSTR file = "file";
thread t(jmmvAsync::run(file), 0);
thread function has this structure:
thread::thread(void (*aFunction)(void *), void * aArg)
Why am I getting wrong types when calling to "thread"?
Error code: COMPILE : error C2664: 'tthread::thread::thread(void (__cdecl *)(void *),void *)' : cannot make conversion of parameter 1 with type 'void' to 'void (__cdecl *)(void *)'
thread function expects paramater 1 to be void (__cdecl *)(void *) and my function is just void. I don't know how to make my function named run the same type as requested.
&jmmvAsync::run, file)?run, not forthread.threadfunction, I need to pass a function to be executed asynchronous, that funcion is void!threadtakes avoid*parameter. Thevoid*it receives when it is called is the second parameter. You're passing the result of calling the function.