get ros2 version in C++
Are there any #define to know which version of ROS2 I'm using in C++ source?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Are there any #define to know which version of ROS2 I'm using in C++ source?
There are no defines in C/C++ out of the box.
That being said if your package depends on ros_environment
the following environment variables are set: ROS_VERSION
(which is either 1
or 2
), ROS_DISTRO
(e.g. dashing
or melodic
), etc.
You can use either to set compiler definitions in your package to be used in conditionals.
If you need more fine grain control you can also use the exact version number of each dependency (e.g. https://github.com/ros2/rmw_cyclonedd...).
Asked: 2019-11-01 16:46:52 -0500
Seen: 1,071 times
Last updated: Nov 02 '19
Cannot build ROS2 humble (rclcpp) with Android NDK
[ROS2] ros2 command stucks without exit
Compilation Error on latest version of RCLCPP
How to get an array of parameters with rclcpp
Frames are moving away from global frame
Best Practices and Recommendations for Creating Moveit2-based ROS2 Actions
Confused adding header files in ROS2
rosdep can't find cyclonedds during foxy install
ROS2 through docker: failed to configure logging: Failed to create log directory