2

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.

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

Comments

5

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

2 Comments

so as far as I understand I have two ways to solve this problem: first - run lua script from C, and than wrap C functions and push them into a stack, and second - build a new module for lua. Am I right?
Correct. You can dynamically bind C functions via the C API, or you can create a module that does that binding.
3

Or the Alien library.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.