Skip to content

A dummy C module that works with FFI and the traditional C api

Notifications You must be signed in to change notification settings

jprjr/lua-demo-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-demo-module

This is just a silly example lua module written in C, I used this to figure out how to create a C module that works in Lua and LuaJIT, as well as with Lua/LuaJIT embedded into a C program.

You'll get slightly different output when using LuaJIT vs Lua, to show whether you're using the traditional C API or the FFI API.

Files:

  • demo.c - the module, compiles to 'demo/core.so' and 'demo/core.a'
  • demo.lua - the loader, it will load 'demo/core.so'
  • main.lua - a silly app that just uses the module

Some examples to try out:

make # builds demo/core.so and demo/core.a
lua main.lua
luajit main.lua
luastatic main.lua demo.lua /path/to/liblua.a demo/core.a -I/path/to/lua/include ; ./main
luastatic main.lua demo.lua /path/to/libluajit.a demo/core.a -I/path/to/luajit/include ; ./main

LICENSE

This is in the public domain.

About

A dummy C module that works with FFI and the traditional C api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published