[libxml2] Simplify xmlexports.h
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Simplify xmlexports.h
- Date: Sun, 6 Dec 2020 16:54:50 +0000 (UTC)
commit acdc2ff3607fe003c2febc25f28954146b3c1636
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu Jun 4 23:02:08 2020 +0200
Simplify xmlexports.h
All the compiler switches essentially set the same macros. The only
exception was MSVC which omitted the "extern" keyword for exported
variables. This in turn broke clang-cl.
This commit rewrites and simplifies the whole header.
Closes #163.
include/libxml/xmlexports.h | 154 +++++++++++---------------------------------
1 file changed, 39 insertions(+), 115 deletions(-)
---
diff --git a/include/libxml/xmlexports.h b/include/libxml/xmlexports.h
index f03af0d0..aceede5e 100644
--- a/include/libxml/xmlexports.h
+++ b/include/libxml/xmlexports.h
@@ -3,43 +3,46 @@
* Description: macros for marking symbols as exportable/importable.
*
* Copy: See Copyright for the status of this software.
- *
- * Author: Igor Zlatovic <igor zlatkovic com>
*/
#ifndef __XML_EXPORTS_H__
#define __XML_EXPORTS_H__
-/**
- * XMLPUBFUN, XMLPUBVAR, XMLCALL
- *
- * Macros which declare an exportable function, an exportable variable and
- * the calling convention used for functions.
- *
- * Please use an extra block for every platform/compiler combination when
- * modifying this, rather than overlong #ifdef lines. This helps
- * readability as well as the fact that different compilers on the same
- * platform might need different definitions.
- */
+#if defined(_WIN32) || defined(__CYGWIN__)
+/** DOC_DISABLE */
+
+#ifdef LIBXML_STATIC
+ #define XMLPUBLIC
+#elif defined(IN_LIBXML)
+ #define XMLPUBLIC __declspec(dllexport)
+#else
+ #define XMLPUBLIC __declspec(dllimport)
+#endif
+
+#if defined(LIBXML_FASTCALL)
+ #define XMLCALL __fastcall
+#else
+ #define XMLCALL __cdecl
+#endif
+#define XMLCDECL __cdecl
+
+/** DOC_ENABLE */
+#else /* not Windows */
/**
- * XMLPUBFUN:
- *
- * Macros which declare an exportable function
- */
-#define XMLPUBFUN
-/**
- * XMLPUBVAR:
+ * XMLPUBLIC:
*
- * Macros which declare an exportable variable
+ * Macro which declares a public symbol
*/
-#define XMLPUBVAR extern
+#define XMLPUBLIC
+
/**
* XMLCALL:
*
- * Macros which declare the called convention for exported functions
+ * Macro which declares the calling convention for exported functions
*/
#define XMLCALL
+
/**
* XMLCDECL:
*
@@ -48,100 +51,21 @@
*/
#define XMLCDECL
-/** DOC_DISABLE */
-
-/* Windows platform with MS compiler */
-#if defined(_WIN32) && defined(_MSC_VER)
- #undef XMLPUBFUN
- #undef XMLPUBVAR
- #undef XMLCALL
- #undef XMLCDECL
- #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
- #define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport)
- #else
- #define XMLPUBFUN
- #if !defined(LIBXML_STATIC)
- #define XMLPUBVAR __declspec(dllimport) extern
- #else
- #define XMLPUBVAR extern
- #endif
- #endif
- #if defined(LIBXML_FASTCALL)
- #define XMLCALL __fastcall
- #else
- #define XMLCALL __cdecl
- #endif
- #define XMLCDECL __cdecl
-#endif
+#endif /* platform switch */
-/* Windows platform with Borland compiler */
-#if defined(_WIN32) && defined(__BORLANDC__)
- #undef XMLPUBFUN
- #undef XMLPUBVAR
- #undef XMLCALL
- #undef XMLCDECL
- #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
- #define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport) extern
- #else
- #define XMLPUBFUN
- #if !defined(LIBXML_STATIC)
- #define XMLPUBVAR __declspec(dllimport) extern
- #else
- #define XMLPUBVAR extern
- #endif
- #endif
- #define XMLCALL __cdecl
- #define XMLCDECL __cdecl
-#endif
-
-/* Windows platform with GNU compiler (Mingw) */
-#if defined(_WIN32) && defined(__MINGW32__)
- #undef XMLPUBFUN
- #undef XMLPUBVAR
- #undef XMLCALL
- #undef XMLCDECL
- /*
- * if defined(IN_LIBXML) this raises problems on mingw with msys
- * _imp__xmlFree listed as missing. Try to workaround the problem
- * by also making that declaration when compiling client code.
- */
- #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
- #define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport) extern
- #else
- #define XMLPUBFUN
- #if !defined(LIBXML_STATIC)
- #define XMLPUBVAR __declspec(dllimport) extern
- #else
- #define XMLPUBVAR extern
- #endif
- #endif
- #define XMLCALL __cdecl
- #define XMLCDECL __cdecl
-#endif
+/*
+ * XMLPUBFUN:
+ *
+ * Macro which declares an exportable function
+ */
+#define XMLPUBFUN XMLPUBLIC
-/* Cygwin platform (does not define _WIN32), GNU compiler */
-#if defined(__CYGWIN__)
- #undef XMLPUBFUN
- #undef XMLPUBVAR
- #undef XMLCALL
- #undef XMLCDECL
- #if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
- #define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport)
- #else
- #define XMLPUBFUN
- #if !defined(LIBXML_STATIC)
- #define XMLPUBVAR __declspec(dllimport) extern
- #else
- #define XMLPUBVAR extern
- #endif
- #endif
- #define XMLCALL __cdecl
- #define XMLCDECL __cdecl
-#endif
+/**
+ * XMLPUBVAR:
+ *
+ * Macro which declares an exportable variable
+ */
+#define XMLPUBVAR XMLPUBLIC extern
/* Compatibility */
#if !defined(LIBXML_DLL_IMPORT)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]