I’m trying to make a thread to handle ZIP archiving:
HANDLE hThread = CreateThread(
NULL,
0,
ZipProcess,
(LPVOID) cmdline.c_str(),
0,
NULL);
I’m passing the command line argument as a string in the lpParameter.
I keep getting this error:
…argument of type ‘void (MyClass::)(std::string) {aka void
(MyClass::)(std::basic_string)}’ does not match
‘LPTHREAD_START_ROUTINE {aka long unsigned int ()(void)}’|
I’ve tried several things – passing by reference, writing to a buffer, a reinterpret_cast, and others, but the error persists. How to fix this?
You’re looking in the wrong spot. The compiler is complaining about the third argument, the thread procedure. Your error looks GCCish, and that says something along the lines of Error passing in argument 3…
To fix it, you need a function signature that actually matches what the function takes (this is an expanded version of the
LPTHREAD_START_ROUTINEtypedef), namely:The three problems with your definition are:
__stdcall) calling convention.std::stringparameter instead ofLPVOID(A.K.A.void *).thisargument, causing a signature mismatch.