Add hello world C lib
This commit is contained in:
parent
8b9eafe94c
commit
f457e31740
|
|
@ -1 +1,2 @@
|
||||||
*.luo
|
*.luo
|
||||||
|
lunaclib/lunaclib.so
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cc -shared $(pkg-config --cflags luajit) lunaclib.c $(pkg-config --libs luajit) -o lunaclib.so
|
||||||
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
|
||||||
|
static int hello(lua_State* L) {
|
||||||
|
puts("Hello World!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct luaL_Reg lib[] = {
|
||||||
|
{"hello", hello},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
int luaopen_lib (lua_State *L) {
|
||||||
|
luaL_openlib(L, "lunaclib", lib, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue