From 7f7ffcf6ed1143b4d4a9e0cf248e190731b2e5f8 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 10 Oct 2023 13:25:55 -0400 Subject: [PATCH] Fix rclcpp_lifecycle inclusion on Windows. (#2331) The comment in the commit explains this clearly, but on Windows ERROR is a macro. The reuse of it, even as an enum, causes compilation errors on downstream users. Push the macro and undefine it so downstream consumers can freely include it. Signed-off-by: Chris Lalancette --- .../node_interfaces/lifecycle_node_interface.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp b/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp index 272c4def27..45748ea55d 100644 --- a/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp +++ b/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp @@ -21,6 +21,14 @@ #include "rclcpp_lifecycle/visibility_control.h" #include "rclcpp/node_interfaces/detail/node_interfaces_helpers.hpp" +// When windows.h is included, ERROR is defined as a macro. So the use of it later in this file, +// even as an enum, causes compilation errors. Work around this by undefining the macro here, +// and then redefining when this header is finished being included. +#if defined(_WIN32) +#pragma push_macro("ERROR") +#undef ERROR +#endif + namespace rclcpp_lifecycle { namespace node_interfaces @@ -108,6 +116,10 @@ class LifecycleNodeInterface } // namespace node_interfaces } // namespace rclcpp_lifecycle +#if defined(_WIN32) +#pragma pop_macro("ERROR") +#endif + RCLCPP_NODE_INTERFACE_HELPERS_SUPPORT( rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface, lifecycle_node)