c2lang/c2compiler

Calculate struct sizes and offsets

Closed this issue · 1 comments

lerno commented

In pull req #79, pointers and built ins are correctly sized, however size for structs are not. Implement the correct sizes for packed and regular structs.

Also, it's not clear what @(packed) means in the context. Is it only that fields are aligned different from the default, or can fields be reordered?

If only the former, should we consider struct reordering (shuffling the order of fields in an optimal way for alignment)? Should it even be default, with a special attribute to prevent reordering (this is Zig's approach)?

I suggest this is added to milestone 2.

fixed