Reputation: 11
I'm wondering why I cannot set the name. This is the error:
It doesn't even let me assign a char.
#include <windows.h>
LRESULT CALLBACK window_callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCmd)
{
//create window class
WNDCLASS window_class = {};
window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.lpszClassName = "Game Window Class";
window_class.lpfnWndProc = window_callback;//callback
//Register class
//Create window
}
Upvotes: -1
Views: 498
Reputation: 598134
WNDCLASS::lpszClassName
is an LPCTSTR
pointer, ie a const TCHAR*
pointer. TCHAR
maps to wchar_t
when UNICODE
is defined, otherwise it maps to char
instead.
You are compiling your project with UNICODE
defined, because lpszClassName
is expecting a wide const wchar_t*
pointer to a Unicode string, but you are giving it a (decayed) narrow const char*
pointer to an ANSI string literal instead, hence the error.
You can either:
undefine UNICODE
in your project settings.
prefix the string literal with L
to make it a Unicode string:
window_class.lpszClassName = L"Game Window Class";
wrap the string literal in the TEXT()
macro:
window_class.lpszClassName = TEXT("Game Window Class");
Upvotes: 1