-
Notifications
You must be signed in to change notification settings - Fork 101
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
Variable name in macro shadows other variable #285
Labels
help wanted
Extra attention is needed
Comments
Yep, that seems totally reasonable to me. We should also consider wrapping the whole thing in a |
felixendres
added a commit
to felixendres/rcutils
that referenced
this issue
Sep 11, 2020
Fix issue ros2#285: Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user. As suggested by @clalancette, also wrapped it into a do-while wrapping.
felixendres
added a commit
to felixendres/rcutils
that referenced
this issue
Sep 11, 2020
Fix issue ros2#285: Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user. As suggested by @clalancette, also wrapped it into a do-while wrapping. Signed-off-by: Felix Endres <felix-endres-github@256bit.org>
clalancette
pushed a commit
to felixendres/rcutils
that referenced
this issue
Oct 1, 2020
Fix issue ros2#285: Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user. As suggested by @clalancette, also wrapped it into a do-while wrapping. Signed-off-by: Felix Endres <felix-endres-github@256bit.org>
clalancette
pushed a commit
that referenced
this issue
Oct 5, 2020
Fix issue #285: Remove the temporary variable in a macro, because the name of the variable may shadow a variable of the macro user. As suggested by @clalancette, also wrapped it into a do-while wrapping. While we are in here, also remove the semicolon and make it a true C-statement. Signed-off-by: Felix Endres <felix-endres-github@256bit.org> Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette I think you can close this. |
@fujitatomoya Good call, fixed by #290, closing. Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
The logging code here triggers a lot of warnings on building. It is because a macro uses the very simple variable name ret, which is also used by the rclcpp function borrow_serialized_message (on my system in /opt/ros/dashing/include/rclcpp/message_memory_strategy.hpp L103) which uses that macro.
I would suggest to skip the assignment to the variable, as it is only used once. Alternatively, use a more unique name that is not likely to be used outside of the macro.
The full warning in question:
The text was updated successfully, but these errors were encountered: