LuaJIT FFI 有多难?
我最近研究了Lua,它看起来真的很好。唯一令人烦恼的是它缺乏(标准)库。但 JIT 编译器附带了一个很好的 FFI C 接口。
来自java背景,我试图尽可能避免C语言,所以我的问题是:有没有人有过LuaJIT的经验,特别是它的FFI接口,以及为一个几乎没有知识的人建立一个库有多困难C?
I recently looked into Lua and it seems really nice. The only annoying thing is its lack of (standard) libraries. But with the JIT compiler comes along a nice FFI C interface.
Coming from a java background, i tried to avoid C as much as possible, so my question: has anyone some experience with LuaJIT, especially its FFI interface, and how difficult is it to set up a library for someone with little to no knowledge in C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说似乎很简单,Mike Pall 在这里有一些很好的教程,lua 邮件列表也包括一些很好的例子,所以也查看档案
Seemed really simple to me, and Mike Pall has some nice tutorials on it here, the lua mailing list also includes some good examples, so check out the archives as well
真的很容易。首先,您需要声明您想要使用的函数。然后,加载目标库并将其分配给 Lua 变量。使用该变量来调用外部函数。
以下是使用 C 数学库中的函数
powf
的示例。Really easy. First, you need to declare the functions that you'd like to use. Then, load the target library and assign it to a Lua variable. Use that variable to call the foreign functions.
Here's an example on using function
powf
from C's math library.