alien icon indicating copy to clipboard operation
alien copied to clipboard

Allow (NUL-terminated) array of chars inside a def_struct

Open 1linux opened this issue 9 years ago • 0 comments

Example:

SMsgError = alien.defstruct{ {"cmdLen", "ulong"}, {"cmd", "ulong"}, {"deviceType","byte"}, {"deviceNo","byte"}, {"errNo","short"}, {"errStr", "char",256}, {"errType","byte"} } Note the optional third element in the struct´s definition.

Now you can:

local instance=SMsgError:new()
instance.errStr="This is a severe error..."

errStr is padded with NUL-bytes. You can also

print( instance.errStr )

1linux avatar Jan 28 '16 12:01 1linux