#include <windows.h>
DWORD Menuthread(LPVOID in) { return 0; }
int main()
{
CreateThread(NULL, NULL, Menuthread, NULL, NULL, NULL);
}
I'm getting the following error message:
error C2664: 'HANDLE CreateThread(LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPDWORD)': cannot convert argument 3 from 'DWORD (__cdecl *)(LPVOID)' to 'LPTHREAD_START_ROUTINE'
note: None of the functions with this name in scope match the target type
If you are compiling on 32-bit visual c++ the default calling convention is
__cdecl.CreateThreadexpects a__stdcallfunction pointer. The simplest fix to this is to use theWINAPImacro which should be defined to the correct calling convention for the platform you are using:Alternatively use
std::threadand just use the default calling convention, this also means you can pass parameters to your function without having to cast them tovoid*: