Skip to content

-Wreorder compiler warnings fix #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged

Conversation

dimitridecious
Copy link
Contributor

Issue

Fix -Wreorder compiler warning in generated parameter header files

This issue is from ros-controls/ros2_controllers#1740, regarding -Wreorder compiler warnings in generated parameter header files. The issue is regarding initialized class members in a different order than they were declared.

/workspaces/ros2_rolling_ws/build/joint_state_broadcaster/include/joint_state_broadcaster/joint_state_broadcaster_parameters.hpp: In constructor ‘joint_state_broadcaster::ParamListener::ParamListener(const std::shared_ptr<rclcpp::node_interfaces::NodeParametersInterface>&, rclcpp::Logger, const std::string&)’:
/workspaces/ros2_rolling_ws/build/joint_state_broadcaster/include/joint_state_broadcaster/joint_state_broadcaster_parameters.hpp:316:22: warning: ‘joint_state_broadcaster::ParamListener::logger_’ will be initialized after [-Wreorder]
  316 |       rclcpp::Logger logger_;
      |                      ^~~~~~~
/workspaces/ros2_rolling_ws/build/joint_state_broadcaster/include/joint_state_broadcaster/joint_state_broadcaster_parameters.hpp:309:19: warning:   ‘std::string joint_state_broadcaster::ParamListener::prefix_’ [-Wreorder]
  309 |       std::string prefix_;
      |                   ^~~~~~~
/workspaces/ros2_rolling_ws/build/joint_state_broadcaster/include/joint_state_broadcaster/joint_state_broadcaster_parameters.hpp:103:5: warning:   when initialized here [-Wreorder]
  103 |     ParamListener(const std::shared_ptr<rclcpp::node_interfaces::NodeParametersInterface>& parameters_interface,
      |     ^~~~~~~~~~~~~

Fixes

Reordered member initialization in the ParamListener constructor to match declaration order.

Copy link
Collaborator

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with the JSB as where I have reported it initially, and this fixes the warning! Thx

@christophfroehlich christophfroehlich requested a review from pac48 June 10, 2025 14:55
@pac48 pac48 merged commit b032766 into PickNikRobotics:main Jun 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants