Skip to content
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

Using C / C++ keywords as package name / field names results into compilation error #272

Closed
firesurfer opened this issue Apr 25, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@firesurfer
Copy link

I realised today that using C++ keywords as fieldnames results into a compilation error.
Example:

bool delete false

Will result into:

rosidl_generator_cpp/iboss_msgs/msg/request_stored_data__struct.hpp:90:16: error: expected member name or ';' after declaration specifiers
  _delete_type delete;

It would be great if either the message generator would throw an error like: Don't use c++ keywords or
the message generator would somehow escape these fields.
If this is not a viable solution for you I think a hint in the documentation would be useful:
https://github.com/ros2/ros2/wiki/About-ROS-Interfaces

@dirk-thomas
Copy link
Member

the message generator would somehow escape these fields.

Absolutely, that is what should happen in each language message generator specific to the keywords in that language.

Related to #118.

@dirk-thomas dirk-thomas added the enhancement New feature or request label Apr 25, 2018
@firesurfer
Copy link
Author

Just for information: I did a short search and apparently it isn't possible in C++ to escape keywords. The usage of keywords as identifiers is forbidden.

@dirk-thomas
Copy link
Member

it isn't possible in C++ to escape keywords

I am not sure I understand your comment. If the delete field would result in a C++ member delete_ it doesn't collide with the keyword anymore. This step is commonly called "mangling" but I assumed what is what you referred to as "escaping".

@firesurfer
Copy link
Author

firesurfer commented Apr 25, 2018

I thought of escaping in the way of doing something like int @class = 0 what would be possible in C#.
Changing a field named delete to delete_ would work of course in C++.

@mikaelarguedas mikaelarguedas added this to the bouncy milestone Apr 26, 2018
@tfoote
Copy link
Contributor

tfoote commented Apr 30, 2018

I've started an design article on this topic at: ros2/design#172

@mikaelarguedas mikaelarguedas added ready Work is about to start (Kanban column) and removed ready Work is about to start (Kanban column) labels May 3, 2018
@wjwwood wjwwood removed this from the bouncy milestone Jul 19, 2018
@dirk-thomas dirk-thomas changed the title Using C++ keywords as fieldnames results into compilation error Using C / C++ keywords as fieldnames results into compilation error Apr 20, 2020
@dirk-thomas dirk-thomas changed the title Using C / C++ keywords as fieldnames results into compilation error Using C / C++ keywords as package name / field names results into compilation error Jun 25, 2020
@firesurfer
Copy link
Author

I guess this can be closed @dirk-thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants