c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

Calculate struct sizes and offsets #84

Closed lerno closed 4 years ago

lerno commented 5 years ago

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.

bvdberg commented 4 years ago

fixed