From c43b27feb25c76e743bd09f41d7b01c909d99d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= <331742+KjellKod@users.noreply.github.com> Date: Sat, 8 Jun 2024 09:22:34 -0600 Subject: [PATCH] correcting and simplifying check for either Visual Studio or Windows --- src/logcapture.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/logcapture.cpp b/src/logcapture.cpp index ad448c9b7..bb1c2ddb4 100644 --- a/src/logcapture.cpp +++ b/src/logcapture.cpp @@ -17,7 +17,7 @@ // For Windows we need force a thread_local install per thread of three // signals that must have a signal handler installed per thread-basis // It is really a royal pain. Seriously Microsoft? Seriously? -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) +#if defined(_WIN32) #define SIGNAL_HANDLER_VERIFY() g3::installSignalHandlerForThread() #else // Does nothing --- enforces that semicolon must be written @@ -85,7 +85,8 @@ void LogCapture::capturef(const char* printf_like_message, ...) { #else static const int kMaxMessageSize = 2048; char finished_message[kMaxMessageSize]; -#if ((defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(__GNUC__)) +// special handling for visual studio +#if defined(_MSC_VER) auto finished_message_len = _countof(finished_message); #else int finished_message_len = sizeof(finished_message); @@ -95,7 +96,7 @@ void LogCapture::capturef(const char* printf_like_message, ...) { va_list arglist; va_start(arglist, printf_like_message); -#if ((defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(__GNUC__)) +#if defined(_MSC_VER) const int nbrcharacters = vsnprintf_s(finished_message, finished_message_len, _TRUNCATE, printf_like_message, arglist); #else const int nbrcharacters = vsnprintf(finished_message, finished_message_len, printf_like_message, arglist);