lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi folks,

Has anybody linked c++ programs with 5.1 and lunar.h before?  I've gotten my program to compile with lunar.h with a few tweaks, but I don't know if there are hidden gotcha's to be aware of.

Here's the old example code changes:

int main(int argc, char *argv[])
{
  lua_State *L = lua_open();

  luaopen_base(L);
  luaopen_table(L);
  luaopen_io(L);
  luaopen_string(L);
  luaopen_math(L);
  luaopen_debug(L);

  Lunar<Account>::Register(L);

  if(argc>1) lua_dofile(L, argv[1]);

  lua_setgcthreshold(L, 0); // collected garbage
  lua_close(L);
  return 0;
}
and my new code:

int main(int argc, char *argv[])
{
  lua_State *L = lua_open();

  luaL_openlibs(L);

  Lunar<Account>::Register(L);

  if(argc>1) luaL_dofile(L, argv[1]);

  lua_gc(L, LUA_GCCOLLECT, 0); // collected garbage
  lua_close(L);
  return 0;
}
it all seems to work.

Mainly, I'm worried that this example doesn't use all the features of lunar.h, and when we dive into it, we get bit by something we don't anticipate.

TIA

Mike