Hi All, I encountered a strange problem with lua integration. Following is the problematic part (full source attached):
type TluaLReg = array of luaL_Reg; var LUA: Plua_State; lib : array of luaL_Reg; //lib : PluaL_Reg; i: Integer; implementation //omitted, see attached source... initialization LUA := luaL_newstate(); luaL_openlibs(LUA); SetLength(lib, 2); //SetLength(TluaLReg(lib), 2); lib[0].name := 'update'; lib[0].func := @l_dat_upd; lib[1].name := 'clear'; lib[1].func := @l_dat_clr; luaL_newlib(LUA, lib); <--Access Violation Here lua_setglobal(LUA, 'data'); finalization lua_close(LUA); end. The above code caused access violation, unless I use the commented blue code to replace the red code. I wonder what's the difference between PluaL_Reg and array of luaL_Reg?? What's more strange is that the same code is OK after I copied it to a separate console mode application. In the attached archive, there are both the problematic project and the OK project. In LUA manual about luaL_newlib(), it said, the 2nd parameter (lib) must be an array not pointer to an array. I am confused what happened here and further more, what's the underlying structure of a normal array in FP (If I am correct, dynamic array is same as pointer, at least that's what I learned in Delphi). My environment is 64 bit Linux 3.5.0 (Mint 14). Thanks a lot. Sincerely, Shannon
luaintf.tar.gz
Description: application/compressed-tar
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
