An open API service indexing awesome lists of open source software.

https://github.com/laserattack/luajit-inline

Allows you to inline the C code in the LuaJIT code
https://github.com/laserattack/luajit-inline

lua luajit luajit-ffi

Last synced: 4 days ago
JSON representation

Allows you to inline the C code in the LuaJIT code

Awesome Lists containing this project

README

          

# LuaJIT Inline

A very simple small module that allows you to inline C code in LuaJIT code

## Deps

LuaJIT, GCC

## Example

```lua
local inline = require("inline")

inline[[
#include
#include
#include

void my_signal_handler(int signum) {
printf("Custom handler received signal: %d\n", signum);
exit(1);
}

void setup_signal_handler() {
signal(SIGINT, my_signal_handler);
}

int add_numbers(int a, int b) {
return a + b;
}

void print_message(const char* msg) {
printf("Message: %s\n", msg);
}
]]

print(add_numbers(1, 2)) --> 3
print_message("hello from C!") --> Message: hello from C!

setup_signal_handler()
print("press Ctrl+C to exit")
while true do end
```