Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling C function from lua

Tags:

c

lua

Can someone tell me is it possible to somehow call c function or simply wrap it into a lua function WITHOUT building a new module.

like image 354
unresolved_external Avatar asked Jul 20 '26 09:07

unresolved_external


2 Answers

If it works for you, try the FFI library. See also luaffi.

like image 103
lhf Avatar answered Jul 21 '26 23:07

lhf


Lua can't call arbitrary C functions - they have to be bound to something in the Lua namespace first. (This is intentional to prevent breaking out of sandboxes in embedded applications.)

like image 36
Amber Avatar answered Jul 21 '26 22:07

Amber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!