From c0c979558c329a33d863effbc7cc3a7ced48860e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 22:49:47 +0100 Subject: [PATCH] Avoid to include windows.h in realtime_helpers.hpp (backport #255) (#256) Co-authored-by: Silvio Traversaro --- include/realtime_tools/realtime_helpers.hpp | 7 +++++-- src/realtime_helpers.cpp | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/realtime_tools/realtime_helpers.hpp b/include/realtime_tools/realtime_helpers.hpp index ef486a49..3a631976 100644 --- a/include/realtime_tools/realtime_helpers.hpp +++ b/include/realtime_tools/realtime_helpers.hpp @@ -35,8 +35,11 @@ #include #ifdef _WIN32 -#include -using NATIVE_THREAD_HANDLE = HANDLE; +// Here we directly use void* instead of including windows.h +// and using HANDLE macro to avoid polluting all the downstream +// compilation units that include the public header realtime_helpers.hpp +// with problematic macros like MIN, MAX or ERROR +using NATIVE_THREAD_HANDLE = void *; #else using NATIVE_THREAD_HANDLE = pthread_t; #endif diff --git a/src/realtime_helpers.cpp b/src/realtime_helpers.cpp index e55894ce..bbabf0bc 100644 --- a/src/realtime_helpers.cpp +++ b/src/realtime_helpers.cpp @@ -28,7 +28,9 @@ #include "realtime_tools/realtime_helpers.hpp" -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#ifdef _WIN32 +#include +#else #include #include #include