aboutsummaryrefslogtreecommitdiff
path: root/xml/details
diff options
context:
space:
mode:
Diffstat (limited to 'xml/details')
-rw-r--r--xml/details/build2/config-vc.h20
-rw-r--r--xml/details/build2/config.h44
-rw-r--r--xml/details/config.hxx16
-rw-r--r--xml/details/expat/config.h14
-rw-r--r--xml/details/export.hxx39
5 files changed, 127 insertions, 6 deletions
diff --git a/xml/details/build2/config-vc.h b/xml/details/build2/config-vc.h
new file mode 100644
index 0000000..4def1f0
--- /dev/null
+++ b/xml/details/build2/config-vc.h
@@ -0,0 +1,20 @@
+/* file : xml/details/build2/config-vc.h
+ * copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC
+ * license : MIT; see accompanying LICENSE file
+ */
+
+/* Configuration file for Windows/VC++ for the build2 build. */
+
+#ifndef XML_DETAILS_CONFIG_VC_H
+#define XML_DETAILS_CONFIG_VC_H
+
+/* Define LIBSTUDXML_BUILD2 for the installed case. */
+#ifndef LIBSTUDXML_BUILD2
+# define LIBSTUDXML_BUILD2
+#endif
+
+// Always little-endian, at least on i686 and x86_64.
+//
+#define LIBSTUDXML_BYTEORDER 1234
+
+#endif /* XML_DETAILS_CONFIG_VC_H */
diff --git a/xml/details/build2/config.h b/xml/details/build2/config.h
new file mode 100644
index 0000000..f03416c
--- /dev/null
+++ b/xml/details/build2/config.h
@@ -0,0 +1,44 @@
+/* file : xml/details/build2/config.h
+ * copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC
+ * license : MIT; see accompanying LICENSE file
+ */
+
+/* Static configuration file for the build2 build. */
+
+#ifndef XML_DETAILS_CONFIG_H
+#define XML_DETAILS_CONFIG_H
+
+/* Define LIBSTUDXML_BUILD2 for the installed case. */
+#ifndef LIBSTUDXML_BUILD2
+# define LIBSTUDXML_BUILD2
+#endif
+
+#ifdef _WIN32
+# ifndef BYTE_ORDER
+# define BIG_ENDIAN 4321
+# define LITTLE_ENDIAN 1234
+# define BYTE_ORDER LITTLE_ENDIAN
+# endif
+#else
+# include <sys/param.h> /* BYTE_ORDER/__BYTE_ORDER, BSD */
+# ifdef BSD
+# include <sys/endian.h> /* BYTE_ORDER */
+# endif
+# ifndef BYTE_ORDER
+# ifdef __BYTE_ORDER
+# define BYTE_ORDER __BYTE_ORDER
+# define BIG_ENDIAN __BIG_ENDIAN
+# define LITTLE_ENDIAN __LITTLE_ENDIAN
+# else
+# error no BYTE_ORDER/__BYTE_ORDER define
+# endif
+# endif
+#endif
+
+#if BYTE_ORDER == BIG_ENDIAN
+# define LIBSTUDXML_BYTEORDER 4321
+#else
+# define LIBSTUDXML_BYTEORDER 1234
+#endif
+
+#endif /* XML_DETAILS_CONFIG_H */
diff --git a/xml/details/config.hxx b/xml/details/config.hxx
index 5f4a19b..da76390 100644
--- a/xml/details/config.hxx
+++ b/xml/details/config.hxx
@@ -5,10 +5,20 @@
#ifndef XML_DETAILS_CONFIG_HXX
#define XML_DETAILS_CONFIG_HXX
-#ifdef _MSC_VER
-# include <xml/details/config-vc.h>
+// Note: the same in expat/config.h
+//
+#ifdef LIBSTUDXML_BUILD2
+# ifdef _MSC_VER
+# include <xml/details/build2/config-vc.h>
+# else
+# include <xml/details/build2/config.h>
+# endif
#else
-# include <xml/details/config.h>
+# ifdef _MSC_VER
+# include <xml/details/config-vc.h>
+# else
+# include <xml/details/config.h>
+# endif
#endif
#endif // XML_DETAILS_CONFIG_HXX
diff --git a/xml/details/expat/config.h b/xml/details/expat/config.h
index b301012..a335147 100644
--- a/xml/details/expat/config.h
+++ b/xml/details/expat/config.h
@@ -1,10 +1,18 @@
#ifndef EXPAT_CONFIG_H
#define EXPAT_CONFIG_H
-#ifdef _MSC_VER
-# include <xml/details/config-vc.h>
+#ifdef LIBSTUDXML_BUILD2
+# ifdef _MSC_VER
+# include <xml/details/build2/config-vc.h>
+# else
+# include <xml/details/build2/config.h>
+# endif
#else
-# include <xml/details/config.h>
+# ifdef _MSC_VER
+# include <xml/details/config-vc.h>
+# else
+# include <xml/details/config.h>
+# endif
#endif
#define BYTEORDER LIBSTUDXML_BYTEORDER
diff --git a/xml/details/export.hxx b/xml/details/export.hxx
index b4c4b58..b9a783d 100644
--- a/xml/details/export.hxx
+++ b/xml/details/export.hxx
@@ -7,6 +7,43 @@
#include <xml/details/config.hxx>
+// 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 LIBSTUDXML_BUILD2
+
+#if defined(LIBSTUDXML_STATIC) // Using static.
+# define LIBSTUDXML_EXPORT
+#elif defined(LIBSTUDXML_STATIC_BUILD) // Building static.
+# define LIBSTUDXML_EXPORT
+#elif defined(LIBSTUDXML_SHARED) // Using shared.
+# ifdef _WIN32
+# define LIBSTUDXML_EXPORT __declspec(dllimport)
+# else
+# define LIBSTUDXML_EXPORT
+# endif
+#elif defined(LIBSTUDXML_SHARED_BUILD) // Building shared.
+# ifdef _WIN32
+# define LIBSTUDXML_EXPORT __declspec(dllexport)
+# else
+# define LIBSTUDXML_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 LIBSTUDXML_EXPORT // Using static or shared.
+#endif
+
+#else // LIBSTUDXML_BUILD2
+
#ifdef LIBSTUDXML_STATIC_LIB
# define LIBSTUDXML_EXPORT
#else
@@ -33,4 +70,6 @@
# endif
#endif
+#endif // LIBSTUDXML_BUILD2
+
#endif // XML_DETAILS_EXPORT_HXX