Permalink
Browse files

Different method of compiling C as C++ (-x c++)

  • Loading branch information...
dabroz authored and matz committed Nov 22, 2016
1 parent 00e6121 commit 18757c8f7be05d9bc8d850180ada4d3fa1fc018d
Showing with 10 additions and 0 deletions.
  1. +5 −0 include/mruby/common.h
  2. +5 −0 tasks/mruby_build.rake
View
@@ -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
View
@@ -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

0 comments on commit 18757c8

Please sign in to comment.