PANIC: unprotected error in call to Lua API (no calling environment)So, I went to the Lua Users Wiki and found some tutorials but still no "hello world" program. So, here it is below
The code itself is self explanatory and the API interface is very interesting. A stack based approach to pass information to/from C from/to lua.
#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main(int argc, char* argv[])
{
char buff[] = "print(\"hello world\")";
int error;
lua_State *L = lua_open();
luaL_openlibs(L);
error = luaL_loadbuffer(L, buff, strlen(buff), "line") ||
lua_pcall(L, 0, 0, 0);
if(error)
{
printf("ERROR: %s", lua_tostring(L, -1));
lua_pop(L, 1);
}
lua_close(L);
return 0;
}
Myopic view of lua
No comments:
Post a Comment