lua-users home
lua-l archive

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


> #define sizelstring(l)  (offsetof(TString, bytes) + ((l) + 1) *
> sizeof(char))

Is it OK if sizelstring(l) sometimes is less than sizeof(TString)?

> 'offsetof' would be better.

I checked here and GCC 10 does not emit warnings if we use offsetof
instead of sizeof.

>  And gcc allows 'char bytes[0];' or 'char bytes[];' .

In this particular case the array size always needs to be at least one
because of the null terminator. That said, a zero-length array would
have avoided creating the extra padding.

-- Hugo
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org