Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid to include windows.h in realtime_helpers.hpp (backport #255) #256

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Jan 10, 2025

#193 added the inclusion of windows.h in the public header realtime_helpers.hpp.

In my limited experience, it is quite important to try to only include windows.h in .cc/.cpp files, as windows.h define many problematic macros (MIN, MAX, ERROR) that induce compilation errors when the realtime_helpers.hpp header is included before rclcpp or ros_control (as several enums are called ERROR in ros_control, see for an example of the confusing errors induced by windows.h ros-controls/gazebo_ros2_control#377 or #204 (comment), just to mention the most recent I found).

For this reason, I think that in this specific case, even if it may seems not ideal, it is a good idea not to include windows.h, and just use directly the value of the HANDLE macro, that is void* (see https://codemachine.com/downloads/win80/winnt.h or https://github.com/Alexpux/mingw-w64/blob/d0d7f784833bbb0b2d279310ddc6afb52fe47a46/mingw-w64-tools/widl/include/winnt.h#L557 for a reference, or if you are on a Windows machine just open your winnt.h file). In general it is not a good idea to assume that a given macro will always have a value, but in this specific case, considering that Win32 API almost never breaks backward compatibility (and that is the reason MIN, MAX and ERROR macros are still around), I think the lesser evil is definitely to using void* in place of HANDLE.


This is an automatic backport of pull request #255 done by [Mergify](https://mergify.com).

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.45%. Comparing base (86ce112) to head (36ecc9a).

Additional details and impacted files
@@           Coverage Diff           @@
##           humble     #256   +/-   ##
=======================================
  Coverage   73.45%   73.45%           
=======================================
  Files           9        9           
  Lines         550      550           
  Branches      215      215           
=======================================
  Hits          404      404           
  Misses         96       96           
  Partials       50       50           
Flag Coverage Δ
unittests 73.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/realtime_helpers.cpp 44.23% <ø> (ø)

@christophfroehlich christophfroehlich merged commit c0c9795 into humble Jan 10, 2025
11 checks passed
@christophfroehlich christophfroehlich deleted the mergify/bp/humble/pr-255 branch January 10, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants