-
Notifications
You must be signed in to change notification settings - Fork 77
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 #255
Conversation
@traversaro the Windows CI is complaining about the change
Can you also fix the pre-commit changes?. Thank you |
I was indeed testing in a dirty env, let me fix that. |
CI seems happy now. Do you prefer that I squash the commits? |
I will test this modification. I recently formatted my PC, so it might take a while to get everything up and running smoothly. Indeed, Windows brings more complications than benefits, and I believe the issues I reported on I am working hard on this and hope to contribute with new solutions this year. |
A bit OT, but if you are interested in running ROS 2 on Windows in robostack (https://robostack.github.io/index.html) we completed a long overdue rebuild of ROS Humble and Jazzy on Windows, you can check the available packages in https://robostack.github.io/humble.html and https://robostack.github.io/jazzy.html). |
@GilmarCorreia Do you think the changes proposed in this PR work for Windows? The CI atleast is happy. If you are then, we can get this merged. If you need some time to test it, we can probably wait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and the CI is also happy. Let's see what @GilmarCorreia says
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #255 +/- ##
=======================================
Coverage 70.12% 70.12%
=======================================
Files 8 8
Lines 492 492
Branches 84 84
=======================================
Hits 345 345
Misses 92 92
Partials 55 55
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hahaha, I'm feeling important @saikishor, thank you! If the CI is happy, I'm happy too. If I run into any trouble, we can discuss it later in a new PR. |
Amazing work! I will test it. |
You and @traversaro are known windows users to us. So, your feedback is really helpful. Thank you for approving it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
@Mergifyio backport humble |
✅ Backports have been created
|
(cherry picked from commit 5b85370)
) Co-authored-by: Silvio Traversaro <[email protected]>
#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 therealtime_helpers.hpp
header is included before rclcpp or ros_control (as several enums are calledERROR
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 isvoid*
(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 yourwinnt.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 reasonMIN
,MAX
andERROR
macros are still around), I think the lesser evil is definitely to usingvoid*
in place ofHANDLE
.