Skip to content

Commit

Permalink
correcting and simplifying check for either Visual Studio or Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
KjellKod committed Jun 8, 2024
1 parent c1dd801 commit c43b27f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/logcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c43b27f

Please sign in to comment.