Skip to content

[Question] Usage of CPP Preprocessor macros for different ROS distros #4129

@MichaelT64

Description

@MichaelT64

While trying to adapt the new features in the main branch to the Humble branch I tried to use CPP Preprocessor capabilities.
I found just a few differences between humble and main for compiling, which can be solved in the following way, e.g.:

#ifdef humble
nav2_util::copy_all_parameters(node, client_node_);
#else
rclcpp::copy_all_parameter_values(node, client_node_);
#endif

In the corresponding CMakeLists.txt FiIes I added the line:
add_compile_definitions( humble )
Due to the lack of cmake knowledge I was not able to use the ROS_DISTRO environment variable or was able to add the compile definition just in one CMakeLists.txt file.

I wonder if this could be a possibility to simplify the development of new features for different ROS distros.

Unfortunately I am just starting with Nav2 so I cannot asses weather the functionality is the exact same but the general way should be possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions