mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Reintroduce mrb_static_assert; #5051
Note that the home brew version of `mrb_static_assert` only works within
the function body. This reverts commit 8f99689.
This commit is contained in:
+9
-3
@@ -62,11 +62,17 @@
|
||||
#define mrb_assert_int_fit(t1,n,t2,max) ((void)0)
|
||||
#endif
|
||||
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
|
||||
#define mrb_static_assert(exp, str) _Static_assert(exp, str)
|
||||
#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || \
|
||||
(defined __cplusplus && __cplusplus >= 201103L)
|
||||
# include <assert.h>
|
||||
# define mrb_static_assert(exp, str) static_assert(exp, str)
|
||||
#else
|
||||
#define mrb_static_assert(exp, str)
|
||||
/* C version of static_assert() */
|
||||
# define mrb_static_assert(cond, str) \
|
||||
do { int assertion_failed[(cond) ? 1 : -1];\
|
||||
(void) assertion_failed; } while(0)
|
||||
#endif
|
||||
#define mrb_static_assert1(exp) mrb_static_assert(exp, #exp)
|
||||
|
||||
#include "mrbconf.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user