[glibmm/glibmm-master-use-dllexport] glibmm: Update glibmmconfig.h.[in|meson] for MSVC
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/glibmm-master-use-dllexport] glibmm: Update glibmmconfig.h.[in|meson] for MSVC
- Date: Mon, 9 Mar 2020 04:21:42 +0000 (UTC)
commit 1f006eef387a519abfff9392dd158332fbac390d
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, so make sure that it is
enabled.
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/ustring.h | 5 +++++
glib/glibmmconfig.h.in | 11 +++++++++++
glib/glibmmconfig.h.meson | 11 +++++++++++
3 files changed, 27 insertions(+)
---
diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h
index c9e24cd1..f0be919f 100644
--- a/glib/glibmm/ustring.h
+++ b/glib/glibmm/ustring.h
@@ -29,6 +29,11 @@
#include <string>
#include <type_traits>
+/* 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 aa158038..7cf76292 100644
--- a/glib/glibmmconfig.h.in
+++ b/glib/glibmmconfig.h.in
@@ -98,7 +98,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 */
diff --git a/glib/glibmmconfig.h.meson b/glib/glibmmconfig.h.meson
index 801e3995..55aa3bac 100644
--- a/glib/glibmmconfig.h.meson
+++ b/glib/glibmmconfig.h.meson
@@ -100,7 +100,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]