title: Compiling LuaJIT as C++?
body: <p>Can't seem to compile LuaJIT with g++ or clang++. Here are some DEBUG. Kindly let me know if I need to provide more information.</p>
  
  <pre><code>$ make CC="g++"
  ==== Building LuaJIT 2.0.4 ====
  make -C src
  make[1]: Entering directory `/home/nutanix/thirdparty/LuaJIT-2.0.4/src'
  HOSTCC    host/minilua.o
  host/minilua.c:370: error: uninitialized const ‘luaO_nilobject_’
  host/minilua.c:604: error: redefinition of ‘const TValue luaO_nilobject_’
  host/minilua.c:370: error: ‘const TValue luaO_nilobject_’ previously declared here
  host/minilua.c:946: error: uninitialized const ‘luaP_opmodes’
  host/minilua.c: In function ‘void luaG_typeerror(lua_State*, const TValue*, const char*)’:
  host/minilua.c:2542: error: invalid conversion from ‘long int’ to ‘const char*’
  host/minilua.c: At global scope:
  host/minilua.c:2620: error: redefinition of ‘const lu_byte luaP_opmodes [38]’
  host/minilua.c:946: error: ‘const lu_byte luaP_opmodes [38]’ previously declared here
  make[1]: *** [host/minilua.o] Error 1
  make[1]: Leaving directory `/home/nutanix/thirdparty/LuaJIT-2.0.4/src'
  make: *** [default] Error 2
  
  $ make CC="clang++"
  ==== Building LuaJIT 2.0.4 ====
  make -C src
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated
  make[1]: Entering directory `/home/nutanix/thirdparty/LuaJIT-2.0.4/src'
  HOSTCC    host/minilua.o
  clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
  host/minilua.c:370:21: error: default initialization of an object of const type
        'const TValue' (aka 'const lua_TValue') without a user-provided default
        constructor
  static const TValue luaO_nilobject_;
                      ^
  host/minilua.c:370:36: note: add an explicit initializer to initialize 'luaO_nilobject_'
  static const TValue luaO_nilobject_;
                                     ^
                                      = {}
  host/minilua.c:604:21: error: redefinition of 'luaO_nilobject_'
  static const TValue luaO_nilobject_={{NULL},0};
                      ^
  host/minilua.c:370:21: note: previous definition is here
  static const TValue luaO_nilobject_;
                      ^
  host/minilua.c:946:22: error: default initialization of an object of const type
        'const lu_byte [38]'
  static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)];
                       ^
  host/minilua.c:946:59: note: add an explicit initializer to initialize 'luaP_opmodes'
  static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)];
                                                            ^
  host/minilua.c:2491:13: error: assigning to 'const char *' from incompatible type 'long'
  ar-&gt;namewhat=(ci)?NULL:NULL;
              ^~~~~~~~~~~~~~~
  host/minilua.c:2540:12: error: cannot initialize a variable of type 'const char *' with
        an rvalue of type 'long'
  const char*kind=(isinstack(L-&gt;ci,o))?
             ^    ~~~~~~~~~~~~~~~~~~~~~
  host/minilua.c:2620:22: error: redefinition of 'luaP_opmodes'
  static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)]={
                       ^
  host/minilua.c:946:22: note: previous definition is here
  static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)];
                       ^
  6 errors generated.
  make[1]: *** [host/minilua.o] Error 1
  make[1]: Leaving directory `/home/nutanix/thirdparty/LuaJIT-2.0.4/src'
  make: *** [default] Error 2
  
  $ clang++ -v
  clang version 3.6.1 (tags/RELEASE_361/final)
  Target: x86_64-redhat-linux-gnu
  Thread model: posix
  Found candidate GCC installation: /opt/rh/devtoolset-3/root/usr/lib/gcc/x86_64-redhat-linux/4.9.2
  Selected GCC installation: /opt/rh/devtoolset-3/root/usr/lib/gcc/x86_64-redhat-linux/4.9.2
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Selected multilib: .;@m64
  
  $ g++ -v
  Using built-in specs.
  Target: x86_64-redhat-linux
  Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
  Thread model: posix
  gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
  
  $ uname -a
  Linux guo-dev 2.6.32-431.17.1.el6.x86_64 #1 SMP Wed May 7 23:32:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  
  <p>So basically, I'm on a CentOS 6.5 system, with g++ 4.4.7 and clang++ 3.6.1. Trying to compile LuaJIT with a C++ compiler so that LuaJIT can safely throw C++ exceptions.</p>
  
  <p>Any help would be greatly appreciated. Thanks!</p>