[glib: 6/7] glib/glib-typeof: Ensure glib_typeof is defined in MSCV C++
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/7] glib/glib-typeof: Ensure glib_typeof is defined in MSCV C++
- Date: Wed, 12 Oct 2022 09:56:27 +0000 (UTC)
commit 9b6cc47bcb2c02e68811cda632efd547532bca42
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Sep 13 22:31:02 2022 +0200
glib/glib-typeof: Ensure glib_typeof is defined in MSCV C++
When compiling with C++ in MSCV, it defines the __cplusplus macro, but
that's set to an old value and it doesn't represent the current c++
standard version (unless when explicitly requested via `/Zc:__cplusplus`).
So, to enable modern features we should rely on `_MSC_LANG` instead,
which represent the value we care about.
glib/glib-typeof.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/glib/glib-typeof.h b/glib/glib-typeof.h
index ffc2a45c5c..106859d7bb 100644
--- a/glib/glib-typeof.h
+++ b/glib/glib-typeof.h
@@ -34,9 +34,12 @@
* This symbol is private.
*/
#undef glib_typeof
-#if (!defined(__cplusplus) || __cplusplus < 201103L) && (G_GNUC_CHECK_VERSION(4, 8) || defined(__clang__))
+#if (!defined(__cplusplus) || (!defined (_MSVC_LANG) && __cplusplus < 201103L)) && \
+ (G_GNUC_CHECK_VERSION(4, 8) || defined(__clang__))
#define glib_typeof(t) __typeof__ (t)
-#elif defined(__cplusplus) && __cplusplus >= 201103L && GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
+#elif defined(__cplusplus) && \
+ (__cplusplus >= 201103L || (defined (_MSVC_LANG) && _MSVC_LANG > 201103L)) && \
+ GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
/* C++11 decltype() is close enough for our usage */
#include <type_traits>
#define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]