ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

if(WIN32) guard is missed for many projects in ROS2

Per my understanding XXX_BUILDING_DLL macro only should be enabled when building on Windows, right?
If that’s true, I don’t understand why “if(WIND32)” guard is missed in so many projects, such as ament itself.
Could anybody explain it?

Thanks

Per my understanding the macros XXX_BUILDING_DLL are processed (replacing XXX_PUBLIC by XXX_EXPORT instead of XXX_IMPORT) only if WIN32 is defined. The macros controlling this behavior can be found in the visibility control file of each package, here ament_index_cpp for example).
So If I understand correctly adding an if(WIN32) would be redundant.

Actually it also affects the _LOCAL visibility macro even on posix machines. So it should always be set, imo. Perhaps it could be given a more generic name that doesn’t contain dll. I think we may have even done this in a couple of packages.

Then it’s better to make a model in ROS2’s core pojects, so that when people are porting other projects could always have right samples.

Yeah, it would be good to have that. I probably won’t spend time updating them right now as we have lots of other important things to do as well, but we would probably take pull requests along those lines (renaming the definition to be more accurate).

Gotcha, thanks for your explanation.