Hi Im new to this comunity and Im in throuble with C heheh. My problem is that:
Im using LUA to create scripting capabilities do my software in C. So, I ve created a file called script.c to suport all script code of my project. See:
script.c (some lines)
int script_start(lua_State *L)
{
L = lua_open();
if (L == NULL)
{
script_error(L, "%s", lua_tostring(L, -1));
return -1;
}
luaopen_base(L);
luaopen_table(L);
luaopen_io(L);
luaopen_string(L);
luaopen_math(L);
luaopen_debug(L);
return 0;
}
int script_end(lua_State *L)
{
lua_close(L);
return 0;
}
As you can see, the this function starts the script engine on the environment parameter L. On the main program I call this function using this form:
Program test.c
int main(int argc, char *argv[])
{
lua_State *L;
script_start(L);
script_end(L); //error here (accces violation)
return 0;
}
All seems to work correctly but Im having acess violation using the L pointer after initializing it. Even on script_end(L) function is not working.
My supositions is that I cant send a empty pointer to be filled on the script_start() funcion. Im thinking right?
All help will be apprecied. (Im Brazilian so, sorry about my english)
thanks in advance