Pitfall of "Unicode in Mingw32"
Mingw32 (version 3.15) does not fully support Unicode. There are a few all-too-common pitfalls.
wWinMain
shall not be used
On Mingw32, wWinMain
function is not supported. wmain
function is also not supported. So, the entry function must be main
function in Unicode.
In addition, _tWinMain
and _tmain
function are only available in Multibyte (not Unicode.) These are mapped to WinMain
and main
in Multibyte.
How to get hInstance
from main function?
Note that hPrevInstance
of wWinMain
arguments is always NULL
on Win32.
How to get lpCmdLine
from main function?
Use GetCommandLine()
function. Unlike lpCmdLine
, the return value of GetCommandLine()
is entire command line, including the program name.
__wargv
shall not be used
__wargv
is also not supported. To get argument list, use CommandLineToArgvW
and GetCommandLineW
function. Note that CommandLineToArgvA
is not defined on win32api.