I have a definition as follows:
#define namef (s, r, x) (p_name ((s), (r), (x)))
My file lua is follows:
tbl= {
name_func = module;
};
my code is as follows:
void getname(void) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
char *arc = "luafun.lua";
if (luaL_dofile(L, arc)) {
printf("Error in %s", arc);
return;
}
lua_getglobal(L, "tbl");
lua_getfield(L, -1, "name_func");
namef(r_name, lua_tostring(L, -1), sizeof(r_name));
lua_close(L);
printf("done");
}
r_name is an array char r_name [11];
but it is giving the following error:
PANIC: unprotected error in call to Lua API (attempt to index a nil value)
I don't know why this is occurring, in C works normally, more to change to lua error occurs