From 6586a59e63d089f38503656949d7aa8734ca8924 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 27 Nov 2017 23:59:42 +0300 Subject: Add support for build2 build --- odb/mysql/details/export.hxx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'odb/mysql/details/export.hxx') diff --git a/odb/mysql/details/export.hxx b/odb/mysql/details/export.hxx index eeccf07..337ea99 100644 --- a/odb/mysql/details/export.hxx +++ b/odb/mysql/details/export.hxx @@ -9,6 +9,43 @@ #include +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported function being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#ifdef LIBODB_MYSQL_BUILD2 + +#if defined(LIBODB_MYSQL_STATIC) // Using static. +# define LIBODB_MYSQL_EXPORT +#elif defined(LIBODB_MYSQL_STATIC_BUILD) // Building static. +# define LIBODB_MYSQL_EXPORT +#elif defined(LIBODB_MYSQL_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_MYSQL_EXPORT __declspec(dllimport) +# else +# define LIBODB_MYSQL_EXPORT +# endif +#elif defined(LIBODB_MYSQL_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_MYSQL_EXPORT __declspec(dllexport) +# else +# define LIBODB_MYSQL_EXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared but in case +// of shared will be sub-optimal compared to having dllimport. +// +# define LIBODB_MYSQL_EXPORT // Using static or shared. +#endif + +#else // LIBODB_MYSQL_BUILD2 + #ifdef LIBODB_MYSQL_STATIC_LIB # define LIBODB_MYSQL_EXPORT #else @@ -35,6 +72,8 @@ # endif #endif +#endif // LIBODB_MYSQL_BUILD2 + #include #endif // ODB_MYSQL_DETAILS_EXPORT_HXX -- cgit v1.1