1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
/* simple example to show a C file linked with ljsyscall */
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdlib.h>
#include <stdio.h>
void lerror(lua_State *L, char *msg) {
fprintf(stderr, "\nFATAL ERROR:\n %s: %s\n\n", msg, lua_tostring(L, -1));
lua_close(L);
exit(1);
}
int main(void) {
lua_State *L;
L = luaL_newstate();
luaL_openlibs(L);
if (luaL_loadstring(L, "require \"test.test\""))
lerror(L, "luaL_loadstring() failed");
if (lua_pcall(L, 0, 0, 0))
lerror(L, "lua_pcall() failed");
lua_close(L);
return 0;
}
|