ros2 / rosidl

Packages which provide the ROS IDL (.msg) definition and code generation.
Apache License 2.0
75 stars 125 forks source link

Consider narrowing the scope of `#undef ERROR` in generated message code #118

Open gerkey opened 8 years ago

gerkey commented 8 years ago

https://github.com/ros2/rosidl/commit/d4264b70387e91b8f46a40ff307881f28ff07c04#commitcomment-17146232

mikaelarguedas commented 7 years ago

This is a known problem that we face is ROS1 as well (e.g. https://github.com/ros/geometry2/issues/172) and it would be great to see how we can address these collisions with Windows defined in the near future

dejanpan commented 6 years ago

This issue has come up again here:

The generated file build\tf2_msgs\rosidl_generator_cpp\tf2_msgs\msg\tf2_error__struct.hpp contains the following code that conflicts with Windows' definition:

  // constants
  enum { NO_ERROR = 0u };

Windows SDK defines macro NO_ERROR in Error.h:

#define NO_ERROR            0

We have confirmed for myself that that culprit is Windows SDK. On a clean installation everything works OK but as soon as we installed Windows SDK the build fails in TF2 (now it fails in Release build too).

@wjwwood says: It might also be possible to change these constants in ROS 2 (with appropriate special handling in the ros1_bridge).

tfoote commented 6 years ago

This is also an issue with 'DELETE' defined in winnt.h: https://github.com/ros2/common_interfaces/issues/44

We'll either need some way to generically protect ourselves from some known set of conflicting strings or else have a blacklist of known strings that must be banned due to windows bad hygene in macro names.

Might it make sense to have a known set of potentially colliding macros that automatically get undefed in our code generators if a conflict is detected?

dirk-thomas commented 6 years ago

Options:

tfoote commented 6 years ago

Related: https://github.com/ros2/design/pull/172