From 8b78b0dc4b4503a813a827b942692976e8392fc5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 2 Mar 2025 19:09:37 +0100 Subject: [PATCH] add windows console window --- app/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index 1eaec56c7..5f9e034b1 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -58,6 +58,24 @@ #include "platform/appleplatform.h" #endif +#if defined(__windows__) +#include +#include +#include + +void attachConsole() { + if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()) { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); + printf("Console attached!\n"); + } else { + MessageBoxA(NULL, "Failed to attach console!", "Error", MB_OK | MB_ICONERROR); + } +} +#endif + #include "logging/logmessagesmodel.h" #include "logging/hudlogmessagesmodel.h" #include "util/qopenhd.h" @@ -237,6 +255,7 @@ int main(int argc, char *argv[]) { #if defined(__windows__) QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); + attachConsole(); #endif QCoreApplication::setOrganizationName("OpenHD");