I upgraded an old project from VC6 to VS2008, and now I get this compile error:
error C2731: 'wWinMain' : function cannot be overloaded
At these lines of code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
The same project compiles fine under VC6.
Thanks everyone, I finally found the real culprit, it's a typo, I use LPSTR lpCmdLine
instead of LPTSTR lpCmdLine
. The real mystery is why it compiled at all under VC6 - it did use wWinMain
, but somehow it was OK for lpCmdLine to be char *
instead of 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 successfully compiled and even ran the program with this function definition under VC6:
int APIENTRY wWinMain(int *hInstance, float hPrevInstance, int *lpCmdLine, float nCmdShow)
{
MessageBox(0,L"Running.",0,0);
return 0;
}
Interestingly, replacing float nCmdShow
to double nCmdShow
does give a linker error, I assume because float is 32-bits but double is not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With