mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
gmacros.h: Improve check for C _Static_assert
Use the GCC/Clang macros __has_extension() and __has_feature() on c_static_assert, which is the documented way for GCC/CLang to check for _Static_assert if C11 mode is not enabled, as suggested by Aleksandr Mezin. As a result, add a private macro that is defined to be __has_extension if it exists, otherwise it is considered to be always false.
This commit is contained in:
parent
7b76995298
commit
f801c84c52
@ -276,6 +276,12 @@
|
|||||||
#define g_macro__has_builtin(x) 0
|
#define g_macro__has_builtin(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __has_extension
|
||||||
|
#define g_macro__has_extension __has_extension
|
||||||
|
#else
|
||||||
|
#define g_macro__has_extension(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G_GNUC_ALLOC_SIZE:
|
* G_GNUC_ALLOC_SIZE:
|
||||||
* @x: the index of the argument specifying the allocation size
|
* @x: the index of the argument specifying the allocation size
|
||||||
@ -754,7 +760,8 @@
|
|||||||
#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 !defined(__cplusplus) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L || defined(__clang__))
|
#if !defined(__cplusplus) && defined(__STDC_VERSION__) && \
|
||||||
|
(__STDC_VERSION__ >= 201112L || 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 (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||||
(defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \
|
(defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \
|
||||||
|
Loading…
Reference in New Issue
Block a user