summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-09-29 10:09:51 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 18:20:29 +0900
commit5069fb15e41998dffef8e0ba566b3a82be369ba3 (patch)
treef4e36e2d7642887b9c968efff6710651a14f48b7 /include
parent7ca59ecea2c15458e74c699da0629c319299e636 (diff)
downloadmruby-5069fb15e41998dffef8e0ba566b3a82be369ba3.tar.gz
mruby-5069fb15e41998dffef8e0ba566b3a82be369ba3.zip
Cause error explicitly from `MRB_TRY()` with `cxx_exception`; ref #5088
`MRB_TRY()` does not work when compiled by C compiler with `cxx_exception` configuration. We should explicitly warn.
Diffstat (limited to 'include')
-rw-r--r--include/mruby/throw.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/mruby/throw.h b/include/mruby/throw.h
index 1f1298d7d..b5ea7312e 100644
--- a/include/mruby/throw.h
+++ b/include/mruby/throw.h
@@ -13,7 +13,9 @@
# endif
#endif
-#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
+#if defined(MRB_ENABLE_CXX_EXCEPTION)
+
+# if defined(__cplusplus)
#define MRB_TRY(buf) try {
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
@@ -22,6 +24,10 @@
#define MRB_THROW(buf) throw((buf)->impl)
typedef mrb_int mrb_jmpbuf_impl;
+# else
+# error "need to be compiled with C++ compiler"
+# endif /* __cplusplus */
+
#else
#include <setjmp.h>
@@ -46,9 +52,11 @@ typedef mrb_int mrb_jmpbuf_impl;
struct mrb_jmpbuf {
mrb_jmpbuf_impl impl;
-#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
+#if defined(MRB_ENABLE_CXX_EXCEPTION)
static mrb_int jmpbuf_id;
+# if defined(__cplusplus)
mrb_jmpbuf() : impl(jmpbuf_id++) {}
+# endif
#endif
};