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

roscpp: Window macro conflict with ERROR constants defined in some msg's. (ros ticket #3817) #161

Open
tfoote opened this issue Jan 31, 2013 · 1 comment
Labels
Milestone

Comments

@tfoote
Copy link
Member

tfoote commented Jan 31, 2013

When including windows.h (mingw cross or msvc builds), we get a conflict due to the constant ERROR defined in some msg files - rosgraph_msg/Log.msg and diagnostics_msg/DiagnosticStatus.msg. They both define constants which later conflict with Windows' ERROR macro.

Possible solutions:

  1. Change the constant name in DiagnosticStatus. Personally, I hate the idea of changing something because of a stupidly named windows macro!

  2. User has to add some inconvenient ifdef/undef code to any file in which they include Log.h or DiagnosticStatus.h. e.g. this is done in roscpp/rosout_appender.cpp:

{{{

ifdef WIN32

#ifdef ERROR
// ach, windows.h polluting everything again,
// clashes with autogenerated rosgraph_msgs/Log.h
#undef ERROR
#endif

endif

}}}

Really annoying for users of some fairly fundamental messages though.

  1. Globally killing the ERROR macro in cpp_common/include/ros/platform.h:

{{{

ifdef WIN32

#ifdef _MSC_VER
#define WIN32_LEAN_AND_MEAN // slimmer compile times
#define WINSOCKAPI // stops windows.h from including winsock.h (and lets us include winsock2.h)
#define NOMINMAX // windows c++ pollutes the environment like any factory
#endif
#include <windows.h>
// *********** Add this check ***********
#ifdef ERROR
// ach, windows.h polluting everything again,
// clashes with autogenerated rosgraph_msgs/Log.h
#undef ERROR
#endif

endif

}}}

Of course, could cause problems for windows users that actually use this macro. I don't know anyone or any program who does these days though. Is it worth finding out if anyone will complain noisily about it?

trac data:

@dirk-thomas
Copy link
Member

The mentioned workarounds are sufficient to deal with the issue. Both changing DiagnosticStatus as well as platform.h would have side effects which might break user code.

@dirk-thomas dirk-thomas removed the minor label Mar 3, 2016
contradict pushed a commit to contradict/ros_comm that referenced this issue Aug 12, 2016
…imestamp

rqt_console: fix loading timestamps from file (fix ros#160)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants