VSE12 Error... C2731: 'WinMain': Function cannot be overloaded

I know it's been a while since I've done any C/C++ or Windows programming but I'm pretty damn sure that everything here is fine and I can't understand why MS:VSE12 is whining at me.
I did even create a new project and try pasting the code in their again because VS sometimes has a tantrum with odd projects and decides to never work with then, but a new project doesn't work.

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "Main.hpp"

LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

INT CALLBACK _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPCTSTR lpCmdLine, INT nCmdShow){
	const TCHAR* CLASS_NAME = TEXT("Window Title Text");

	WNDCLASS wc = {0, WinProc, 0, 0, hInstance, NULL, LoadCursor(NULL, IDC_ARROW), NULL, NULL, CLASS_NAME};
	RegisterClass(&wc);
	

	HWND hWnd;
	{
		RECT rec = {0, 0, 800, 600};
		AdjustWindowRect(&rec, WS_OVERLAPPEDWINDOW, false);
		hWnd = CreateWindowEx(NULL, CLASS_NAME, CLASS_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rec.right - rec.left, rec.top - rec.bottom, NULL, NULL, hInstance, NULL);
	}
	if(!hWnd){
		MessageBox(NULL, TEXT("CreateWindowEx() returned NULL handle\nApplication will terminate"), TEXT("Failed"), MB_ICONERROR | MB_OK);
		return GetLastError();
	}
	
	ShowWindow(hWnd, nCmdShow);

	MSG msg;
	while(GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return 0;
}

LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
    //You know the drill here, but it's not relevant to the problem
}


Main.hpp
1
2
3
4
5
6
7
8
#ifndef MAIN_HPP
#define MAIN_HPP
#define WIN32_LEAN_AND_MEAN

#include <tchar.h>
#include <Windows.h>

#endif 


EDIT: The first project had VS set up to not use UNICODE, the second project was left as defaults (which does auto define UNICODE), but the error is present on both and the character set doesn't really matter... The only difference being that without UNICODE defined the compiler error says
'WinMain': Function cannot be overloaded
and with it defined the error says
'wWinMain': Function cannot be overloaded
(Same error code C2731)

EDIT2: I'm not trying to find anything wrong with the code because I don't thing their is (if you spot something tell me though as it could be that), I've seen many people with the same problem and all the answers have been along the lines of
You've put LPCTSTR for wWinMain when it should be LPCWSTR
Even though VS automatically defines UNICODE so this doesn't matter other than bad practice for mixing the types as it can potentially cause issues...
Does anyone know why VS would complain about the main functions being overloaded when they're clearly not?
Last edited on
Only going to bump once incase it was missed and someone does have an answer?
Interesting note, using the auto generated code under Win32 Application will compile and run fine, and then when I edit the content of the functions a little I get the error again that WinMain (or 'w') cannot be overloaded, even though the function definition hasn't changed at all.
Topic archived. No new replies allowed.