I'm quite new in Lua, and I want to embed Lua into our game project using C++. The first thing I notice, Lua is allowed to be compiled as C++ code, and from the doc, I've learned that this will eliminate the 'extern C' wrapping around Lua's headers, and also the error handling will be C++ exception instead of longjump/setjump.
My question is, besides these two differences, is there any other real benefit to compile Lua code as C++ code? These two don't real convince me, as, 1) it doesn't bother me to wrap c headers with 'extern C', 2) our project doesn't allow exception, so I have to change in luaconf.h to use longjump/setjump any way.
Those are the benefits of compiling Lua as C++. The extern "C"
thing isn't even really the point; it's all about exception handling. And while your application forbids exceptions, not every C++ application does.
If you're using all of C++, you either have to take steps to prevent exceptions from passing through Lua (not the easiest thing in the world unless you're using a wrapper like Luabind) or to compile Lua as C++.
There are no other benefits of compiling Lua as C++. Exception handling is the reason why Lua can be compiled as C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With