ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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_cyclonedds/pull/51).