From e7f3abad3accefcf0281dc9b881306ba3daacf0d Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu Date: Mon, 20 Jul 2026 05:55:32 +1000 Subject: [PATCH] Fix ublox_msgs Windows portability This upstreams the Windows-focused part of the RoboStack ublox_msgs build fix. On Windows, the system ERROR macro can collide with the ublox_msgs::Message::INF::ERROR constant. Guarding the macro locally lets the public header keep its existing API. Enabling CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS exports the ublox_msgs support library symbols for downstream consumers. Origin: patch/ros-rolling-ublox-msgs.win.patch, authored by Daisuke Nishimatsu. Signed-off-by: Tobias Fischer --- ublox_msgs/CMakeLists.txt | 4 ++++ ublox_msgs/include/ublox_msgs/ublox_msgs.hpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ublox_msgs/CMakeLists.txt b/ublox_msgs/CMakeLists.txt index 4e3db305..54940932 100644 --- a/ublox_msgs/CMakeLists.txt +++ b/ublox_msgs/CMakeLists.txt @@ -10,6 +10,10 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() +if(WIN32) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + find_package(ament_cmake_ros REQUIRED) find_package(rosidl_default_generators REQUIRED) find_package(sensor_msgs REQUIRED) diff --git a/ublox_msgs/include/ublox_msgs/ublox_msgs.hpp b/ublox_msgs/include/ublox_msgs/ublox_msgs.hpp index b1ac7155..13ef3cb8 100644 --- a/ublox_msgs/include/ublox_msgs/ublox_msgs.hpp +++ b/ublox_msgs/include/ublox_msgs/ublox_msgs.hpp @@ -191,7 +191,16 @@ namespace Message { } // namespace RXM namespace INF { +#if defined(_WIN32) && defined(ERROR) +#pragma push_macro("ERROR") +#undef ERROR +#define UBLOX_MSGS_RESTORE_ERROR_MACRO +#endif static const uint8_t ERROR = 0x00; +#if defined(UBLOX_MSGS_RESTORE_ERROR_MACRO) +#pragma pop_macro("ERROR") +#undef UBLOX_MSGS_RESTORE_ERROR_MACRO +#endif static const uint8_t WARNING = 0x01; static const uint8_t NOTICE = 0x02; static const uint8_t TEST = 0x03;