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.
This commit is contained in:
Marco Trevisan (Treviño) 2022-09-13 22:31:02 +02:00
parent c19904d6e8
commit 9b6cc47bcb

View File

@ -34,9 +34,12 @@
* This symbol is private. * This symbol is private.
*/ */
#undef glib_typeof #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) #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 */ /* C++11 decltype() is close enough for our usage */
#include <type_traits> #include <type_traits>
#define glib_typeof(t) typename std::remove_reference<decltype (t)>::type #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type