“APIENTRY _tWinMain” and “WINAPI WinMain” difference

_tWinMain is just a #define shortcut in tchar.h to the appropriate version of WinMain. If _UNICODE is defined, then _tWinMain expands to wWinMain. Otherwise, _tWinMain is the same as WinMain. The relevant macro looks something like this (there’s actually a lot of other code interspersed): #ifdef _UNICODE #define _tWinMain wWinMain #else #define _tWinMain WinMain #endif

Undefined reference to WinMain (C++ MinGW)

This example code uses wWinMain but One thing to note is that Visual C++ supports a “wWinMain” entry point where the “lpCmdLine” parameter is a “LPWSTR”. You would typically use the “_tWinMain” preprocessor definition for your entry point and declare “LPTSTR lpCmdLine” so that you can easily support both ANSI and Unicode builds. However, the … Read more

WINMAIN and main() in C++ (Extended)

About the functions. The C and C++ standards require any program (for a “hosted” C or C++ implementation) to have a function called main, which serves as the program’s startup function. The main function is called after zero-initialization of non-local static variables, and possibly but not necessarily (!, C++11 §3.6.2/4) this call happens after dynamic … Read more

What is a message pump?

A message loop is a small piece of code that exists in any native Windows program. It roughly looks like this: MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } The GetMessage() Win32 API retrieves a message from Windows. Your program typically spends 99.9% of its time there, waiting for Windows to tell … Read more