gplugin/gplugin

Add visibility information to exported API

7 months ago, Elliott Sales de Andrade
2e7031dd2fde
Parents 50162e3b83fe
Children a1475628f0c2
Add visibility information to exported API

This allows linking against GPlugin on Windows.

This is based on GLib's setup.

Testing Done:
Compiled on Windows and now tests are able to link properly.

Reviewed at https://reviews.imfreedom.org/r/2665/
--- a/gplugin/gplugin-version.h Tue Oct 17 02:49:27 2023 -0500
+++ b/gplugin/gplugin-version.h Tue Oct 17 02:57:36 2023 -0500
@@ -26,7 +26,28 @@
#include <gplugin/gplugin-version-defs.h>
-#define _GPLUGIN_EXTERN extern
+/* clang-format tries to remove the space after 'if', which confuses
+ * gobject-introspection, so turn it off temporarily. */
+/* clang-format off */
+#if (defined(_WIN32) || defined(__CYGWIN__)) && \
+ !defined(GPLUGIN_STATIC_COMPILATION)
+/* clang-format on */
+#define _GPLUGIN_EXPORT __declspec(dllexport)
+#define _GPLUGIN_IMPORT __declspec(dllimport)
+#elif __GNUC__ >= 4
+#define _GPLUGIN_EXPORT __attribute__((visibility("default")))
+#define _GPLUGIN_IMPORT
+#else
+#define _GPLUGIN_EXPORT
+#define _GPLUGIN_IMPORT
+#endif
+#ifdef GPLUGIN_COMPILATION
+#define _GPLUGIN_API _GPLUGIN_EXPORT
+#else
+#define _GPLUGIN_API _GPLUGIN_IMPORT
+#endif
+
+#define _GPLUGIN_EXTERN _GPLUGIN_API extern
#ifdef GPLUGIN_DISABLE_DEPRECATION_WARNINGS
#define GPLUGIN_DEPRECATED _GPLUGIN_EXTERN