I've been recently doing a bit of research on various Lua/C binding possibilities and came across LuaJIT with its pretty nice FFI library. I've been immediately impressed by how simple it is to expose C functions and datatypes directly to Lua without the need of writing a single line of C code or using an external binding tool (it's similar to Python'sctypes to some degree). The library basically parses plane C declarations provided as a string and than does the binding automatically by looking up the symbols exported by a mapped binary. The best thing is that the symbols don't need to come from a DLL, but even a regular executable (exe) can export them! That's what makes FFI perfect for embedding Lua directly into an executable. There's no need for additional wrapping DLLs! This makes the whole setup simpler and enables additional optimizations and inlining.

// Please note that despite the fact that we build this code as a regular// executable (exe), we still use __declspec(dllexport) to export// symbols. Without doing that FFI wouldn't be able to locate them!