-
Notifications
You must be signed in to change notification settings - Fork 119
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Consider the following structure:
if (condition)
RCUTILS_LOG_ERROR("error");
else
{
RCUTILS_LOG_INFO("info");
}
With the current ROS2 rcutils, this code will fail to compile with something like:
/home/ubuntu/teleop_twist_ws/src/badmacro/src/badmacro.cpp: In member function ‘int BadMacro::main()’:
/home/ubuntu/teleop_twist_ws/src/badmacro/src/badmacro.cpp:21:7: error: expected ‘}’ before ‘else’
else
^~~~
In file included from /opt/ros/bouncy/include/rclcpp/client.hpp:39:0,
from /opt/ros/bouncy/include/rclcpp/callback_group.hpp:23,
from /opt/ros/bouncy/include/rclcpp/node_interfaces/node_base_interface.hpp:25,
from /opt/ros/bouncy/include/rclcpp/executor.hpp:31,
from /opt/ros/bouncy/include/rclcpp/executors/multi_threaded_executor.hpp:24,
from /opt/ros/bouncy/include/rclcpp/executors.hpp:21,
from /opt/ros/bouncy/include/rclcpp/rclcpp.hpp:144,
from /home/ubuntu/teleop_twist_ws/src/badmacro/src/badmacro.cpp:3:
I have a minimal reproducer of this problem over at https://github.com/clalancette/badmacro . We probably need to wrap all of these macros in the do { ... } while(0) construct to make them safe in these circumstances.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working