Skip to content

Commit

Permalink
Fix rclcpp_lifecycle inclusion on Windows. (#2331)
Browse files Browse the repository at this point in the history
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 <clalancette@gmail.com>
  • Loading branch information
clalancette authored Oct 10, 2023
1 parent 13abc1b commit 7f7ffcf
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 7f7ffcf

Please sign in to comment.