将Lua编译为C ++除了避免“extern C”和get“C ++ exception”,有什么好处? [英] What is the benefit to compile Lua as C++ other than avoid 'extern C' and get 'C++ exception'?

查看:140
本文介绍了将Lua编译为C ++除了避免“extern C”和get“C ++ exception”,有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Lua很新,我想使用C ++将Lua嵌入到我们的游戏项目中。第一件事我注意到,Lua被允许编译为C ++代码,并从文档,我知道,这将消除'extern C'环绕Lua的头,并且错误处理将是C ++异常,而不是longjump / setjump。

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.

我的问题是,除了这两个区别之外,将Lua代码编译为C ++代码有什么其他真正的好处吗?这两个不真正说服我,因为,1)它不打扰我用'extern C'包装c头,2)我们的项目不允许异常,所以我必须改变在luaconf.h使用

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.

推荐答案

这些是将Lua编译为C ++的好处。 externC事情甚至不是真正的点;它都是关于异常处理。

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.

如果你使用C ++的所有 ,你必须采取步骤以防止异常通过Lua(不是世界上最简单的东西,除非你使用像Luabind这样的包装器)或者将Lua编译为C ++。

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++.

没有将Lua编译为C ++的其他好处。异常处理为什么Lua可以编译为C ++的原因。

There are no other benefits of compiling Lua as C++. Exception handling is the reason why Lua can be compiled as C++.

这篇关于将Lua编译为C ++除了避免“extern C”和get“C ++ exception”,有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆