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



commit 85755d77791f02fecc15735e6e6845946e94db8f
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
    
    Drop all the compatibility bits for Visual Studio 2013 as Visual Studio
    2013 does not have sufficient C++11 support to build glibmm.
    
    Make sure that we do enable GLIBMM_CAN_USE_THREAD_LOCAL as Visual Studio
    2015 or later has thread_local, but we must also ensure that we do 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 2017 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    | 18 +++---------------
 glib/glibmmconfig.h.meson | 19 ++++---------------
 4 files changed, 13 insertions(+), 31 deletions(-)
---
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..5e3dba0d 100644
--- a/glib/glibmmconfig.h.in
+++ b/glib/glibmmconfig.h.in
@@ -117,23 +117,11 @@
 # define GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED 1
 # pragma warning (disable: 4786 4355 4800 4181)
 
-#if (_MSC_VER < 1900)
-/* The C++-11 keywords noexcept and thread_local are supported on
- * Visual Studio 2013 via Microsoft-specific extensions, but are
- * supported directly in Visual Studio 2015
- */
-
-#define _ALLOW_KEYWORD_MACROS 1
-
-#ifndef noexcept
-#define noexcept _NOEXCEPT
-#endif
-
-#ifndef thread_local
-#define thread_local __declspec (thread)
+/* 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 /* _MSC_VER < 1900 */
 #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..6fff5057 100644
--- a/glib/glibmmconfig.h.meson
+++ b/glib/glibmmconfig.h.meson
@@ -118,27 +118,16 @@
 # define GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS 1
 # define GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 1
 # define GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION 1
+# define GLIBMM_CAN_USE_THREAD_LOCAL 1
 # define GLIBMM_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS 1
 # define GLIBMM_CAN_USE_NAMESPACES_INSIDE_EXTERNC 1
 # pragma warning (disable: 4786 4355 4800 4181)
 
-#if (_MSC_VER < 1900)
-/* The C++-11 keywords noexcept and thread_local are supported on
- * Visual Studio 2013 via Microsoft-specific extensions, but are
- * supported directly in Visual Studio 2015
- */
-
-#define _ALLOW_KEYWORD_MACROS 1
-
-#ifndef noexcept
-#define noexcept _NOEXCEPT
-#endif
-
-#ifndef thread_local
-#define thread_local __declspec (thread)
+/* 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 /* _MSC_VER < 1900 */
 #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]