sizeof and __offsetof
sizeof(Type)gives the size of a type in bytes.sizeof(value)gives the size of the value's V type, including when its storage moves to the heap. Value expressions such assizeof(values[0])andsizeof(record.field)use the visible local or parameter, including when it shadows a module constant.__offsetof(Struct, field_name)gives the offset in bytes of a struct field.
struct Foo {
a int
b int
}
assert sizeof(Foo) == 8
assert __offsetof(Foo, a) == 0
assert __offsetof(Foo, b) == 4