diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-13 02:56:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-13 02:56:14 +0000 |
commit | 54af8757b337a7347a230d450cfda9e2b0c94560 (patch) | |
tree | 709753e211aee6f76724c045f360271ecda0fede /internal.h | |
parent | 867aafe409b8c8ba8c443d9c0651b804538fa71f (diff) |
internal.h: STATIC_ASSERT
* st.c: include "internal.h" for STATIC_ASSERT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/internal.h b/internal.h index ca3649d0f6..5f38b4e146 100644 --- a/internal.h +++ b/internal.h @@ -63,15 +63,18 @@ extern "C" { #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0]))) -#define STATIC_ASSERT_TYPE(name) static_assert_##name##_check -#define STATIC_ASSERT(name, expr) typedef int STATIC_ASSERT_TYPE(name)[1 - 2*!(expr)] - #define GCC_VERSION_SINCE(major, minor, patchlevel) \ (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \ ((__GNUC__ > (major)) || \ (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \ (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel)))) +#if GCC_VERSION_SINCE(4, 6, 0) +# STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr) +#else +# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)] +#endif + #define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1) #define SIGNED_INTEGER_MAX(sint_type) \ (sint_type) \ @@ -516,7 +519,6 @@ VALUE rb_ary_tmp_new_fill(long capa); const VALUE args_to_new_ary[] = {__VA_ARGS__}; \ if (__builtin_constant_p(n)) { \ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \ - (void)sizeof(STATIC_ASSERT_TYPE(rb_ary_new_from_args)); /* suppress warnings by gcc 4.8 or later */ \ } \ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \ }) |