[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (rc3) now available
- From: 云风 Cloud Wu <cloudwu@...>
- Date: Wed, 13 May 2020 11:10:42 +0800
Roberto Ierusalimschy <roberto@inf.puc-rio.br> 于2020年5月13日周三 上午12:28写道:
>
> This code wastes up to seven bytes (due to alignment), compared with
> the original version. A better option would be to use 'offsetof' to
> compute the size of the rest of the structure:
>
> #define sizelstring(l) (offsetof(TString, bytes) + ((l) + 1) * sizeof(char))
'offsetof' would be better. And gcc allows 'char bytes[0];' or 'char bytes[];' .
It's C99 standard, but MSVC doesn't support it :(
https://stackoverflow.com/questions/20221012/unsized-array-declaration-in-a-struct
--
http://blog.codingnow.com
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org