Skip to content

[hardware_interface] Windows build fails with fatal error C1189: #error: "The mutex.hpp header is not supported on Windows platforms" #2302

@traversaro

Description

@traversaro

First of all, thanks a lot for all the amazing work on ros2_control. I know that Windows support is currently relying on external contributors, and I do not have an immediate fix for this issue, but I think it was useful to track it in the main ros2_control repo instead of an external repo. If you disagree, no problem and just close the issue.

Describe the bug

Since #2086, the compilation of hardware interface on Windows is failing with:

2025-05-29T01:32:32.8503781Z  │ │   Ignoring COMPILE_WARNING_AS_ERROR target property and CMAKE_COMPILE_WARNING_AS_ERROR variable.
2025-05-29T01:32:32.9731687Z  │ │   Generating hardware_interface/version.h
2025-05-29T01:32:32.9982947Z  │ │   Building Custom Rule %SRC_DIR%/ros-jazzy-hardware-interface/src/work/CMakeLists.txt
2025-05-29T01:32:33.0149502Z  │ │   Ignoring COMPILE_WARNING_AS_ERROR target property and CMAKE_COMPILE_WARNING_AS_ERROR variable.
2025-05-29T01:32:33.1918018Z  │ │   Building Custom Rule %SRC_DIR%/ros-jazzy-hardware-interface/src/work/CMakeLists.txt
2025-05-29T01:32:33.2088832Z  │ │   Ignoring COMPILE_WARNING_AS_ERROR target property and CMAKE_COMPILE_WARNING_AS_ERROR variable.
2025-05-29T01:32:33.7759948Z  │ │   actuator.cpp
2025-05-29T01:32:35.9991128Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(408,7): warning C4003: not enough arguments for function-like macro invocation 'GET_6TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:35.9994086Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(416,7): warning C4003: not enough arguments for function-like macro invocation 'GET_4TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:35.9997105Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(425,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:35.9999973Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(426,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0003651Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(428,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0006308Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(482,7): warning C4003: not enough arguments for function-like macro invocation 'GET_6TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0009436Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(484,1): warning C4003: not enough arguments for function-like macro invocation 'GET_6TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0012326Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(492,7): warning C4003: not enough arguments for function-like macro invocation 'GET_4TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0015166Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(494,1): warning C4003: not enough arguments for function-like macro invocation 'GET_4TH_ARG' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0017693Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(499,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0020096Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(500,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.0022284Z  │ │ %SRC_DIR%\ros-jazzy-hardware-interface\src\work\include\hardware_interface/handle.hpp(502,9): warning C4068: unknown pragma 'GCC' [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.1137593Z  │ │ %PREFIX%/Library/include/realtime_tools\realtime_tools/mutex.hpp(21,1): fatal error C1189: #error:  "The mutex.hpp header is not supported on Windows platforms" [%SRC_DIR%\build\hardware_interface.vcxproj]
2025-05-29T01:32:36.1325427Z  │ │   component_parser.cpp
2025-05-29T01:32:37.6521650Z  │ │   resource_manager.cpp

The problem is that realtime_tools\realtime_tools/mutex.hpp and the realtime_tools::prio_inherit_mutex are not available on Windows, but they are included also on Windows. To fix this I guess it is necessary either to support realtime_tools::prio_inherit_mutex on Windows or some kind of abstraction layer that uses realtime_tools::prio_inherit_mutex when available, or a normal mutex on Windows, but I do not know enough about this for now.

To Reproduce

Basically compile on Windows but I do not have a minimal reproducer for this at the moment, but I can work on one if I try to tackle the issue (unfortunately I can't promise when).

Expected behavior

Compile is successful.

Screenshots

Environment (please complete the following information):

Additional context

Downstream context: RoboStack/ros-jazzy#54 (comment) .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions