From a220b86672f9369f1e72ff2ddf497387c4f5f2b5 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 2 Feb 2023 00:33:15 +0100 Subject: [PATCH] Disable code relying on `unistd.h` when compiling with MSVC Not sure what to do instead, so for now let's just disable the logging from the signal handler completely for MSVC builds so the code at least compiles. --- cli/helper.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cli/helper.cpp b/cli/helper.cpp index 766bc66..a209a19 100644 --- a/cli/helper.cpp +++ b/cli/helper.cpp @@ -14,7 +14,10 @@ #include #include +#if !defined(PLATFORM_WINDOWS) || defined(PLATFORM_MINGW) +// for write(STDOUT_FILENO, data, size) - not sure what to use with MSVC #include +#endif #include #include @@ -116,13 +119,17 @@ void InterruptHandler::handler(int signum) // finalize log and print warning, prevent using std::cout which could lead to undefined behaviour if (!logLineFinalized) { logLineFinalized = true; +#if !defined(PLATFORM_WINDOWS) || defined(PLATFORM_MINGW) write(STDOUT_FILENO, "\n", 1); +#endif } +#if !defined(PLATFORM_WINDOWS) || defined(PLATFORM_MINGW) if (EscapeCodes::enabled) { write(STDOUT_FILENO, "\e[1;33mWarning:\e[0m \e[1mSignal received, trying to abort ongoing process ...\e[0m\n", 82); } else { write(STDOUT_FILENO, "Warning: Signal received, trying to abort ongoing process ...\n", 63); } +#endif // call custom handler s_handler();