diff --git a/templates/cpp-template-default/proj.win32/main.cpp b/templates/cpp-template-default/proj.win32/main.cpp index 09df3c0489..ae97b09606 100644 --- a/templates/cpp-template-default/proj.win32/main.cpp +++ b/templates/cpp-template-default/proj.win32/main.cpp @@ -33,7 +33,19 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); + // create the application instance +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + // create the application instance AppDelegate app; - return Application::getInstance()->run(); + int ret = Application::getInstance()->run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif }