I wrote a simple app code using WINAPI. Visual Studio detects no errors but while building appears an error of "external symbol". Unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ);
here's the code:
include "windows.h"
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI winMain(In HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInst, In LPSTR lpCmdLine, In int nCmdShow) {
TCHAR zcClassName[] = L"Window Class";
HWND hMainWnd;
MSG msg;
WNDCLASSEX wndClass;
wndClass.cbSize = sizeof(wndClass);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = wndProc;
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = zcClassName;
wndClass.cbWndExtra = NULL;
wndClass.cbClsExtra = NULL;
wndClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wndClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hInstance = hInst;
if (!RegisterClassEx(&wndClass)) {
MessageBox(NULL, L"Class Not Registered", L"FATAL ERROR", MB_OK);
return NULL;
}
hMainWnd = CreateWindow(zcClassName, L"Test Program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, NULL, CW_USEDEFAULT, NULL, (HWND)NULL, NULL, HINSTANCE(hInst), NULL);
ShowWindow(hMainWnd, nCmdShow);
UpdateWindow(hMainWnd);
while (GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return wndProc(hWnd, msg, wParam, lParam);
}
}
why isn't it compiling?