From 22244469d47a503d7a6089299fc8e5e6407188d2 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 29 Dec 2022 19:00:40 +0800 Subject: [PATCH] Add win32 console for cpp template [skip ci] --- templates/cpp-template-default/proj.win32/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 }