Error C2731: "wWinMain": The function cannot be overloaded
I upgraded an old project from VC6 to VS2008 and now I am getting this compilation error:
error C2731: 'wWinMain' : function cannot be overloaded
In these lines of code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
The same project is compiled under VC6.
source to share
Thanks everyone, I finally found the real culprit, it's a typo, I'm using LPSTR lpCmdLine
instead LPTSTR lpCmdLine
. The real mystery is why it compiles at all under VC6 - it used to wWinMain
, but somehow it was okay to have lpCmdLine char *
instead WCHAR *
.
Now I changed it to:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
And it works under VS2008 too.
Edit: I compiled successfully and even ran the program with this function definition in VC6:
int APIENTRY wWinMain(int *hInstance, float hPrevInstance, int *lpCmdLine, float nCmdShow)
{
MessageBox(0,L"Running.",0,0);
return 0;
}
Interestingly, replacing float nCmdShow
with double nCmdShow
gives a linker error, I assume the float is 32 bit, but the double is not.
source to share