Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@gvdhoorn is correct, it's an oversight that you cannot do:

if (condition)
  RCLCPP_INFO(...);
else
  RCLCPP_INFO(...);

The macro's contents should be wrapped within a do { ... } while(0). This is done in the equivalent C API's, see:

https://github.com/ros2/rcutils/blob/9e1f5593763cfdc64f2e590dbafb0c316926f628/resource/logging_macros.h.em#L66-L75

But the rclcpp one's do not do this:

https://github.com/ros2/rclcpp/blob/43f891dac8ff27839079f1c8b39527972ce65fc6/rclcpp/resource/logging.hpp.em#L92-L104

I'd recommend opening an issue on rclcpp and ideally providing a pull request to help us fix it :D