gencpp icon indicating copy to clipboard operation
gencpp copied to clipboard

Compilation fail for messages with c++ keywords as field names

Open mikepurvis opened this issue 7 years ago • 1 comments

The Python generation code contains logic to append with underscore any fields that match a Python keyword:

https://github.com/ros/genpy/blob/45ecd5415fc4711a3afbdf3c2923b59fa742b436/src/genpy/generator.py#L224-L225

However, there's no such thing in the gencpp code, so we got tripped up when we had a message with established Python usage that had class as a field name, and then got used in C++ and wouldn't compile.

For now we've simply renamed our field to class_, but it would be great to see this transformation happen in gencpp itself, as it does in genpy.

mikepurvis avatar Jun 27 '17 13:06 mikepurvis

This would be an interesting feature. It should be made sure that e.g. an existing field class_ doesn't collide with a new field class which gets the suffix automatically to avoid the collision though.

Please consider to provide a pull request for this since the maintainer will likely not have time to implement the feature.

dirk-thomas avatar Jun 27 '17 16:06 dirk-thomas