summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-14 14:44:59 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-14 17:58:06 +0900
commit08c2a9dc599021668e11dee2f099a204122eab90 (patch)
tree67e5f7b69e2d2c1199cc9310d1d91e8c5854debd
parent715955ff27206351dcf509eb3c60e0927ad9a708 (diff)
Introduce RUBY_DEBUG flag macro
When RUBY_DEBUG is turned on, all RUBY_ASSERT() macros will be enabled regardless RUBY_NDEBUG.
-rw-r--r--include/ruby/assert.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/ruby/assert.h b/include/ruby/assert.h
index aef36b8d48..f8930a7bba 100644
--- a/include/ruby/assert.h
+++ b/include/ruby/assert.h
@@ -28,9 +28,12 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *));
# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
RUBY_ASSERT_MESG(!(cond) || (expr), mesg)
#endif
-#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(!RUBY_NDEBUG+0, expr, #expr)
+#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RUBY_DEBUG+(!RUBY_NDEBUG+0), expr, #expr)
#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr)
+#ifndef RUBY_DEBUG
+# define RUBY_DEBUG 0
+#endif
#ifndef RUBY_NDEBUG
# ifdef NDEBUG
# define RUBY_NDEBUG 1