Notes
To initialize Struct fields, you can provide as arguments :
C Struct new instance
The Struct object allows you to define a C struct. To create a new C struct instance from this definition, simply call this object with or without initialization values.
Example
local c = require "c"
-- Defines a RECT Struct definition
local RECT = c.Struct("iiii", "left", "top", "right", "bottom")
-- Creates a new RECT instance with table initialization
local rect1 = RECT {
top = 110,
left = 140,
right = 200,
bottom = 320
}
-- Creates a new RECT instance with arguments initalization
local rect2 = RECT(140, 110, 200, 320)
-- Creates a new RECT instance without initialization
local rect3 = RECT()
print(rect1.left) -- prints 140
print(rect2.left) -- prints 140
print(rect3.left) -- prints 0