lua-users home
lua-l archive

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


Asko Kauppi wrote:

I would check data alignment settings. The luaL_openl() macro (which you're not using) does "sizeof(tbl) / sizeof(tbl[0])" which only works if there are no gaps between the table entries. For this reason, such entries should be N*4 or N*8 bytes wide. I don't know if the authors have considered this. So switch you compiler's data alignment to 2 or 4 bytes and see what happens.


I am pretty sure that sizeof(tbl)/sizeof(tbl[0]) is a safe C/C++ idiom.
C/C++ arrays don't contain "gaps", if padding is needed it is already
inside the structs.

(Actually when using the idiom you have to be careful that tbl is an array,
things go wrong if it is a pointer, which of course otherwise works as an
array in C/C++)



		Eero