Skip to content

Conversation

@J-Cowsert
Copy link
Contributor

Remove the -Wc++20-extensions warning triggered by capturing a structured binding in a lambda.

ROS 2 still targets C++17 only (REP-2000). Capturing structured bindings directly is a C++20 extension, so we avoid it by using .second explicitly instead. The unused first element (hw_name / entry.first) is omitted to avoid the separate -Wunused-variable warning/error.

No functional change.

Fixes #2574

Tested locally:

  • colcon build --packages-select hardware_interface
  • colcon test --packages-select hardware_interface - all tests pass

@christophfroehlich christophfroehlich added the backport-kilted Triggers PR backport to ROS 2 kilted. label Nov 19, 2025
Copy link
Member

@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 see this pattern four times in this file, can you please fix them all at once?

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

Too advanced hahaha
I added it as the GCC supported it from 22.04 on. Sure, let's change it

@J-Cowsert
Copy link
Contributor Author

@christophfroehlich I'm only finding one occurrence of a structured binding capture within a lambda. Could you please clarify if you mean structured bindings in general that should be fixed, or if there's a different pattern I'm missing?

Copy link
Member

@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 just looked for the & [hw_name, limiters] : pattern, but the problem is the lambda capture which happens only once. sorry for the confusion

@christophfroehlich christophfroehlich added the backport-jazzy Triggers PR backport to ROS 2 jazzy. label Nov 19, 2025
@christophfroehlich christophfroehlich merged commit 1757bd1 into ros-controls:master Nov 19, 2025
17 of 18 checks passed
mergify bot pushed a commit that referenced this pull request Nov 19, 2025
mergify bot pushed a commit that referenced this pull request Nov 19, 2025
@J-Cowsert J-Cowsert deleted the fix/c++20-structured-binding-capture branch November 19, 2025 16:52
robkwan pushed a commit to robkwan/ros2_control that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-jazzy Triggers PR backport to ROS 2 jazzy. backport-kilted Triggers PR backport to ROS 2 kilted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should we fix -Wc++20-extensions?

3 participants