How do I determine the memory offset of a type's field?

Let’s say I have a custom composite type:

struct Foo
    bar::Int
    biz::Float64
end

While in this simple case, I can easily calculate the offset of biz myself (8 bytes), is there a function that will do this for me in a more generic way? Something akin to C’s offsetof macro?

Just found it: fieldoffset

1 Like