diff options
| author | KOBAYASHI Shuji <[email protected]> | 2020-08-11 20:25:40 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2020-08-11 20:47:20 +0900 |
| commit | bab7e9f032e7ddf7a1c29dc37a8afee47106dddf (patch) | |
| tree | 63e148c2f90d077a7e64b5507312226fe11ed095 /include/mruby.h | |
| parent | ab5726d4e42ca653957eaaf9abc863392ecbe678 (diff) | |
| download | mruby-bab7e9f032e7ddf7a1c29dc37a8afee47106dddf.tar.gz mruby-bab7e9f032e7ddf7a1c29dc37a8afee47106dddf.zip | |
Use normal `static_assert` in `mrb_static_assert` as much as possible
* `_Static_assert` can also be used with `-std=gnu99` on GCC >= 4.6.
* `static_assert` can be used on MSVC.
* `static_assert` can be used even on old G++/Clang++ if
`__GXX_EXPERIMENTAL_CXX0X__` is defined.
Diffstat (limited to 'include/mruby.h')
| -rw-r--r-- | include/mruby.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/mruby.h b/include/mruby.h index 8625d4521..1ca87b390 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -62,12 +62,16 @@ #define mrb_assert_int_fit(t1,n,t2,max) ((void)0) #endif -#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || \ - (defined __cplusplus && __cplusplus >= 201103L) -# include <assert.h> +#if (defined __cplusplus && __cplusplus >= 201103L) || \ + (defined _WIN32 && !defined __MINGW32__) || \ + (defined __GXX_EXPERIMENTAL_CXX0X__) /* for old G++/Clang++ */ # define mrb_static_assert(exp, str) static_assert(exp, str) +#elif defined __STDC_VERSION__ && \ + ((__STDC_VERSION__ >= 201112L) || \ + (defined __GNUC__ && __GNUC__ * 100 + __GNUC_MINOR__ >= 406)) +# define mrb_static_assert(exp, str) _Static_assert(exp, str) #else -/* C version of static_assert() */ +# /* alternative implementation of static_assert() */ # define _mrb_static_assert_cat0(a, b) a##b # define _mrb_static_assert_cat(a, b) _mrb_static_assert_cat0(a, b) # ifdef __COUNTER__ |
