-
Notifications
You must be signed in to change notification settings - Fork 125
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
Map ROS char into C signed char #211
Conversation
This looks to me like a good reason to revive the char/byte usefulness in our IDL format. The design doc defines:
I'm not convinced that changing the tests to stop testing the entire range of the char type is a long term solution. Maybe reviving #190 and the associated Pull Requests will be more adequate. If we are looking for a short term solution I think that we should explicitly assign this to a |
Thanks for iterating on this. Can c6e45ca be reverted now that signed char is used ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also create a corresponding PR for the design article which specifies the type mapping to be in sync.
@@ -1,7 +1,7 @@ | |||
bool def_bool_1 true | |||
bool def_bool_2 false | |||
byte def_byte 66 | |||
char def_char -66 | |||
char def_char 67 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be reverted.
Same below for test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -166,7 +166,7 @@ def primitive_value_to_c(type_, value): | |||
if type_ == 'bool': | |||
return 'true' if value else 'false' | |||
|
|||
if type_ in ['byte', 'char', 'int8', 'int16', 'int32', 'int64']: | |||
if type_ in ['byte', 'char', 'signed char', 'int8', 'int16', 'int32', 'int64']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signed char
is not a valid type name. Valid type names are only the keys of the MSG_TYPE_TO_C
dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm once CI passed
The C standard leaves it to the compiler implementor to decide whether a
char
is signed or unsigned:As a result, it's not portable to assign a negative value to a
char
and then test the result. This came up when building on aarch64:This PR changes the mapping of the ROS
char
to be asigned char
in C. Requires ros2/rmw_fastrtps#99.I'll also do a PR to update the design doc to specify the new mapping, but these code changes can be reviewed independently of that.
For a smaller test case, consider this program:
On linux/x86 it looks good:
But on linux/aarch64 not so much: