Skip to content

Commit

Permalink
Avoid to include windows.h in realtime_helpers.hpp (backport #255) (#256
Browse files Browse the repository at this point in the history
)

Co-authored-by: Silvio Traversaro <[email protected]>
  • Loading branch information
mergify[bot] and traversaro authored Jan 10, 2025
1 parent 86ce112 commit c0c9795
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions include/realtime_tools/realtime_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
#include <vector>

#ifdef _WIN32
#include <windows.h>
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
Expand Down
4 changes: 3 additions & 1 deletion src/realtime_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

#include "realtime_tools/realtime_helpers.hpp"

#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#ifdef _WIN32
#include <windows.h>
#else
#include <sched.h>
#include <sys/capability.h>
#include <sys/mman.h>
Expand Down

0 comments on commit c0c9795

Please sign in to comment.