lua-users home
lua-l archive

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


Karel Tuma wrote:
> Excerpts from Alexander Nasonov's message of 2014-09-14 20:19:08 +0200:
> > Dirk Laurie wrote:
> > > Is there any difference between *l and l[] in C?
> > 
> > There is no difference for function arguments but luaL_newlib()
> > and luaL_newlibtable() are macros. Because the documentation
> > emphasises that l must be an array, I suspect the implementation
> > calculates sizeof(l) / sizeof(l[0]).
> > 
> > Alex
> 
> Luckily not, it looks for NULL terminator in the name field.

#define luaL_newlibtable(L,l)   \
  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)

#define luaL_newlib(L,l)        (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))

Alex