From 0c9786de3a5d0315a252854305bf771196e34224 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Jan 2011 13:39:16 +0000 Subject: [PATCH] Fix entry point in Unicode build of the MFC sample. MFC needs the entry point to be wWinMainCRTStartup() in Unicode builds but the bakefile-generated projects use the default WinMain() so the sample didn't link in Unicode. Fix this by providing WinMain() which simply forwards to wWinMainCRTStartup() as this seems to work for all MSVC/CRT versions. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/mfc/mfctest.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index 69146772d3..a67b88d026 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -49,10 +49,6 @@ // first: mfc[version][u]d.lib // - [version] -> 42 or 70 or 80 etc // - u if using Unicode -// -// (4) Unicode builds may produce the linker error "unresolved external symbol _WinMain@16". -// MFC requires you to manually add the Unicode entry point to the linker settings, -// Entry point symbol -> wWinMainCRTStartup #include "stdafx.h" @@ -128,6 +124,18 @@ DECLARE_APP(MyApp) // notice use of IMPLEMENT_APP_NO_MAIN() instead of the usual IMPLEMENT_APP! IMPLEMENT_APP_NO_MAIN(MyApp) +#ifdef _UNICODE +// In Unicode build MFC normally requires to manually change the entry point to +// wWinMainCRTStartup() but to avoid having to modify the project options to do +// it we provide an adapter for it. +extern "C" int wWinMainCRTStartup(); + +int WINAPI WinMain(HINSTANCE, HINSTANCE, char *, int) +{ + wWinMainCRTStartup(); +} +#endif // _UNICODE + CMainWindow::CMainWindow() { LoadAccelTable( wxT("MainAccelTable") );