[glib/msvc-static-assert] gmacros.h: Use static_assert on MSVC if possible
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/msvc-static-assert] gmacros.h: Use static_assert on MSVC if possible
- Date: Tue, 2 Jul 2019 03:53:25 +0000 (UTC)
commit 7b91440ca48ab1e06920299a205359a5668398ef
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Jul 2 11:48:43 2019 +0800
gmacros.h: Use static_assert on MSVC if possible
Visual Studio 2010 and later support static_assert on both C and C++,
but we can only enable it for plain-C code on Visual Studio 2013 and
later, as apparently the static_assert macro implementation will carry
out something after defining certain variables.
For C++ code, we use static_assert on Visual Studio 2010 and later.
glib/gmacros.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index fd81416dd..2764d9552 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -736,7 +736,9 @@
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
-#elif defined(__cplusplus) && __cplusplus >= 201103L
+#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
+ (defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \
+ (defined (_MSC_VER) && (_MSC_VER >= 1800))
#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false")
#else
#ifdef __COUNTER__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]