mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-12 20:36:15 +01:00
Make clang++ happier when using G_STATIC_ASSERT
clang++ says it supports _Static_assert but then will complain that it's a C11 extension and that you should not use it in C++ code (which imho is fair enough) So try to detect a C++ compiler first and then the C compiler, similarly to what is done for the G_NORETURN case
This commit is contained in:
parent
4263cd8cbb
commit
925d2b3b1f
@ -863,18 +863,18 @@
|
|||||||
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
|
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
|
||||||
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
|
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
|
||||||
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
|
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
|
||||||
#if (G_C_STD_CHECK_VERSION (11) || \
|
#if G_CXX_STD_CHECK_VERSION (11)
|
||||||
|
#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false")
|
||||||
|
#elif (G_C_STD_CHECK_VERSION (11) || \
|
||||||
g_macro__has_feature(c_static_assert) || g_macro__has_extension(c_static_assert))
|
g_macro__has_feature(c_static_assert) || g_macro__has_extension(c_static_assert))
|
||||||
#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
|
#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
|
||||||
#elif G_CXX_STD_CHECK_VERSION (11)
|
|
||||||
#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false")
|
|
||||||
#else
|
#else
|
||||||
#ifdef __COUNTER__
|
#ifdef __COUNTER__
|
||||||
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
|
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
|
||||||
#else
|
#else
|
||||||
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED
|
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED
|
||||||
#endif
|
#endif
|
||||||
#endif /* G_C_STD_CHECK_VERSION (11) */
|
#endif /* G_CXX_STD_CHECK_VERSION (11) */
|
||||||
#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1]))
|
#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1]))
|
||||||
#endif /* !__GI_SCANNER__ */
|
#endif /* !__GI_SCANNER__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user