Reputation: 57257
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?
Upvotes: 0
Views: 1918
Reputation: 61920
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_ROUTINE
typedef), namely:
DWORD (WINAPI *lpStartAddress)(LPVOID)
The three problems with your definition are:
__stdcall
) calling convention.std::string
parameter instead of LPVOID
(A.K.A. void *
).this
argument, causing a signature mismatch.Upvotes: 1