From 81d16d95c0752568f6d9c2ffa92b3b289a3eed4d Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 1 Jun 2021 09:08:28 +0800 Subject: [PATCH] Explicitly export exception types. --- include/gdalcpp.hpp | 4 +++- include/osmium/geom/factory.hpp | 3 ++- include/osmium/geom/util.hpp | 4 +++- include/osmium/handler/check_order.hpp | 3 ++- include/osmium/index/index.hpp | 4 +++- include/osmium/index/map.hpp | 3 ++- include/osmium/io/error.hpp | 4 +++- include/osmium/memory/buffer.hpp | 2 +- include/osmium/osm/item_type.hpp | 4 +++- include/osmium/util/compatibility.hpp | 6 ++++++ 10 files changed, 28 insertions(+), 9 deletions(-) diff --git a/include/gdalcpp.hpp b/include/gdalcpp.hpp index 7aaae16af..f5a163f73 100644 --- a/include/gdalcpp.hpp +++ b/include/gdalcpp.hpp @@ -42,6 +42,8 @@ DEALINGS IN THE SOFTWARE. #include #include +#include + #include #include #include @@ -63,7 +65,7 @@ namespace gdalcpp { /** * Exception thrown for all errors in this class. */ - class gdal_error : public std::runtime_error { + class OSMIUM_EXPORT gdal_error : public std::runtime_error { std::string m_driver; std::string m_dataset; diff --git a/include/osmium/geom/factory.hpp b/include/osmium/geom/factory.hpp index e47fb0e38..9736cd140 100644 --- a/include/osmium/geom/factory.hpp +++ b/include/osmium/geom/factory.hpp @@ -44,6 +44,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include @@ -56,7 +57,7 @@ namespace osmium { * Exception thrown when an invalid geometry is encountered. An example * would be a linestring with less than two points. */ - class geometry_error : public std::runtime_error { + class OSMIUM_EXPORT geometry_error : public std::runtime_error { std::string m_message; osmium::object_id_type m_id; diff --git a/include/osmium/geom/util.hpp b/include/osmium/geom/util.hpp index 7faf828be..d6da943b6 100644 --- a/include/osmium/geom/util.hpp +++ b/include/osmium/geom/util.hpp @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include #include @@ -42,7 +44,7 @@ namespace osmium { * Exception thrown when a projection object can not be initialized or the * projection of some coordinates can not be calculated. */ - struct projection_error : public std::runtime_error { + struct OSMIUM_EXPORT projection_error : public std::runtime_error { explicit projection_error(const std::string& what) : std::runtime_error(what) { diff --git a/include/osmium/handler/check_order.hpp b/include/osmium/handler/check_order.hpp index f15f41d92..e55edfed0 100644 --- a/include/osmium/handler/check_order.hpp +++ b/include/osmium/handler/check_order.hpp @@ -39,6 +39,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include @@ -50,7 +51,7 @@ namespace osmium { * Exception thrown when a method in the CheckOrder class detects * that the input is out of order. */ - struct out_of_order_error : public std::runtime_error { + struct OSMIUM_EXPORT out_of_order_error : public std::runtime_error { osmium::object_id_type object_id; diff --git a/include/osmium/index/index.hpp b/include/osmium/index/index.hpp index 55472700d..aeff0a06b 100644 --- a/include/osmium/index/index.hpp +++ b/include/osmium/index/index.hpp @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include #include #include @@ -45,7 +47,7 @@ namespace osmium { * Exception signaling that an element could not be * found in an index. */ - struct not_found : public std::runtime_error { + struct OSMIUM_EXPORT not_found : public std::runtime_error { explicit not_found(const std::string& what) : std::runtime_error(what) { diff --git a/include/osmium/index/map.hpp b/include/osmium/index/map.hpp index 6b49e1e97..a301fe79e 100644 --- a/include/osmium/index/map.hpp +++ b/include/osmium/index/map.hpp @@ -33,6 +33,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #include @@ -47,7 +48,7 @@ DEALINGS IN THE SOFTWARE. namespace osmium { - struct map_factory_error : public std::runtime_error { + struct OSMIUM_EXPORT map_factory_error : public std::runtime_error { explicit map_factory_error(const char* message) : std::runtime_error(message) { diff --git a/include/osmium/io/error.hpp b/include/osmium/io/error.hpp index c471b18b5..09c824529 100644 --- a/include/osmium/io/error.hpp +++ b/include/osmium/io/error.hpp @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include #include @@ -41,7 +43,7 @@ namespace osmium { /** * Exception thrown when some kind of input/output operation failed. */ - struct io_error : public std::runtime_error { + struct OSMIUM_EXPORT io_error : public std::runtime_error { explicit io_error(const std::string& what) : std::runtime_error(what) { diff --git a/include/osmium/memory/buffer.hpp b/include/osmium/memory/buffer.hpp index 93d37e950..daefc7d8b 100644 --- a/include/osmium/memory/buffer.hpp +++ b/include/osmium/memory/buffer.hpp @@ -55,7 +55,7 @@ namespace osmium { * to write data into a buffer and it doesn't fit. Buffers with internal * memory management will not throw this exception, but increase their size. */ - struct buffer_is_full : public std::runtime_error { + struct OSMIUM_EXPORT buffer_is_full : public std::runtime_error { buffer_is_full() : std::runtime_error{"Osmium buffer is full"} { diff --git a/include/osmium/osm/item_type.hpp b/include/osmium/osm/item_type.hpp index 1fd75250e..8181e3c6d 100644 --- a/include/osmium/osm/item_type.hpp +++ b/include/osmium/osm/item_type.hpp @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include #include // IWYU pragma: keep #include @@ -192,7 +194,7 @@ namespace osmium { * probably means the buffer contains different kinds of objects than were * expected or that there is some kind of data corruption. */ - struct unknown_type : public std::runtime_error { + struct OSMIUM_EXPORT unknown_type : public std::runtime_error { unknown_type() : std::runtime_error("unknown item type") { diff --git a/include/osmium/util/compatibility.hpp b/include/osmium/util/compatibility.hpp index 100954058..6d071fe25 100644 --- a/include/osmium/util/compatibility.hpp +++ b/include/osmium/util/compatibility.hpp @@ -51,4 +51,10 @@ DEALINGS IN THE SOFTWARE. # define OSMIUM_DEPRECATED #endif +#if defined(_MSC_VER) +# define OSMIUM_EXPORT __declspec(dllexport) +#else +# define OSMIUM_EXPORT __attribute__ ((visibility("default"))) +#endif + #endif // OSMIUM_UTIL_COMPATIBILITY_HPP