[glibmm/use-dllexport-2-62] glibmm: Update glibmmconfig.h.[in|meson] for MSVC



commit 61eafe9ebe8001146b13732fb94987fa26406e59
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Mar 9 11:58:33 2020 +0800

    glibmm: Update glibmmconfig.h.[in|meson] for MSVC
    
    Visual Studio 2015 or later has thread_local, but we must not mark
    DispatcherNotifier for export as a result, since thread_local conflicts
    with __declspec(dllexport).
    
    Also update for Visual Studio 2017+ as the compiler does allow static
    members to be initialized inline to std::string::npos
    (GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS), but use a work
    around for pre-Visual Studio 2015 so that we do not get a linker error
    as GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS is not supported.

 glib/glibmm/dispatcher.h  |  2 +-
 glib/glibmm/ustring.h     |  5 +++++
 glib/glibmmconfig.h.in    | 11 +++++++++++
 glib/glibmmconfig.h.meson | 11 +++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/glib/glibmm/dispatcher.h b/glib/glibmm/dispatcher.h
index 62515cf5..91340300 100644
--- a/glib/glibmm/dispatcher.h
+++ b/glib/glibmm/dispatcher.h
@@ -24,7 +24,7 @@ namespace Glib
 {
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
-class GLIBMM_API DispatchNotifier;
+class DispatchNotifier;
 #endif
 
 /** Signal class for inter-thread communication.
diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h
index 5f6da2d7..24b2f525 100644
--- a/glib/glibmm/ustring.h
+++ b/glib/glibmm/ustring.h
@@ -29,6 +29,11 @@
 #include <cstddef> /* for std::ptrdiff_t */
 #endif
 
+/* work around linker error on Visual Studio if we don't have GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS */
+#if (_MSC_VER >= 1600) && !defined (GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS)
+const std::basic_string<char>::size_type std::basic_string<char>::npos = 
(std::basic_string<char>::size_type) -1;
+#endif
+
 namespace Glib
 {
 
diff --git a/glib/glibmmconfig.h.in b/glib/glibmmconfig.h.in
index f534812f..d569c478 100644
--- a/glib/glibmmconfig.h.in
+++ b/glib/glibmmconfig.h.in
@@ -133,7 +133,18 @@
 #define thread_local __declspec (thread)
 #endif
 
+#else
+
+/* thread_local is supported on Visual Studio 2015+ */
+#define GLIBMM_CAN_USE_THREAD_LOCAL 1
+
 #endif /* _MSC_VER < 1900 */
+
+/* We have GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS for Visual Studio 2017+ */
+#if (_MSC_VER >= 1910)
+#define GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS 1
+#endif
+
 #endif /* GLIBMM_MSC */
 
 /* Dummy macro definition for compatibility with old code that expects
diff --git a/glib/glibmmconfig.h.meson b/glib/glibmmconfig.h.meson
index c9de14a8..a0cb7563 100644
--- a/glib/glibmmconfig.h.meson
+++ b/glib/glibmmconfig.h.meson
@@ -138,7 +138,18 @@
 #define thread_local __declspec (thread)
 #endif
 
+#else
+
+/* thread_local is supported on Visual Studio 2015+ */
+#define GLIBMM_CAN_USE_THREAD_LOCAL 1
+
 #endif /* _MSC_VER < 1900 */
+
+/* We have GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS for Visual Studio 2017+ */
+#if (_MSC_VER >= 1910)
+#define GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS 1
+#endif
+
 #endif /* GLIBMM_MSC */
 
 /* Enable DLL-specific stuff only when not building a static library */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]