Search code examples
c++mingw

wWinmain, Unicode, and Mingw


I am working on learning the Windows API and am using mingw as my compiler with Code::Blocks as my IDE.

I have run into an issue with using the wWinMain function. I used the program located here: link text.

It compiles fine in VS C++ 2008 Express, but when using mingw I get the error:

undefined reference to WinMain@16

I have figured out what the problem is (I think). By replacing the wWinMain with just Winmain and the string pointer PWSTR with LPSTR, it compiles perfectly. My question is, how can I fix this? And if not, is not using Unicode that big of a deal?


Solution

  • Use the plain (non unicode) WinMain function, and then get your unicode command line using GetCommandLineW. MinGW doesn't know about wWinMain.

    You are probably going to find working on MinGW difficult; last time I used it it did not support most of the wchar_t components of the C++ standard library (i.e. std::wifstream, std::wstring, etc) which made interfacing with Unicode Windows bits difficult.

    Do you have anything against MSVC?