ros-perception / image_common

Common code for working with images in ROS
http://www.ros.org/wiki/image_common
124 stars 219 forks source link

Use IMAGE_TRANSPORT_PUBLIC at class level for windows gcc build #316

Open felixf4xu opened 1 month ago

felixf4xu commented 1 month ago

Hi,

When I compile this project and then some other project which uses this image_common on Windows with gcc, I have this kind of error:

image_transport/image_transport/camera_publisher.hpp:68:3: error: function 'image_transport::CameraPublisher::CameraPublisher()' definition is marked dllimport 68 | CameraPublisher() = default; | ^~~~~~~

This might be a gcc only issue, when a function is dllimport but it has a definition (function body) at the same time.

When I had a similar issue with gcc before, I chose to a safe way by moving the function body from .h to .cpp. But this time it's different since CameraPublisher() = default; can only be in the .h file. So in this PR I moved the IMAGE_TRANSPORT_PUBLIC from member function level to class level.

There are some places where I can move the function body from .h to .cpp, but to be consistent, class level of IMAGE_TRANSPORT_PUBLIC is used for all places.

ahcorde commented 1 month ago