summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby/common.h5
-rw-r--r--tasks/mruby_build.rake5
2 files changed, 10 insertions, 0 deletions
diff --git a/include/mruby/common.h b/include/mruby/common.h
index 3745c58ea..338044c2f 100644
--- a/include/mruby/common.h
+++ b/include/mruby/common.h
@@ -9,8 +9,13 @@
#ifdef __cplusplus
+#ifdef MRB_ENABLE_CXX_EXCEPTION
+#define MRB_BEGIN_DECL
+#define MRB_END_DECL
+#else
# define MRB_BEGIN_DECL extern "C" {
# define MRB_END_DECL }
+#endif
#else
/** Start declarations in C mode */
# define MRB_BEGIN_DECL
diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake
index cff45ddf8..cde996aae 100644
--- a/tasks/mruby_build.rake
+++ b/tasks/mruby_build.rake
@@ -120,6 +120,7 @@ module MRuby
def enable_cxx_abi
return if @cxx_exception_disabled or @cxx_abi_enabled
compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION) }
+ compilers.each { |c| c.flags << '-x c++'}
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
@cxx_abi_enabled = true
end
@@ -135,9 +136,13 @@ module MRuby
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
+#ifndef MRB_ENABLE_CXX_EXCEPTION
extern "C" {
+#endif
#include "#{src}"
+#ifndef MRB_ENABLE_CXX_EXCEPTION
}
+#endif
#{src == "#{MRUBY_ROOT}/src/error.c"? 'mrb_int mrb_jmpbuf::jmpbuf_id = 0;' : ''}
EOS