5 Likes
The fact that our
teakeeps changing, makes me believe that, for reasons I don’t know, Zig decided to put the pointer to our name at the start.
I guess the compiler sorts the field storage in decreasing order of alignment. A slice has larger alignment than a u32, so the slice goes first.
2 Likes
for anyone that didnt read to the section about defined layouts and safety.
you shouldn’t rely on that behaviour, the layout of normal zig structs is explicitly left to the compiler to do whatever it wants, it could and will change what it does.
For example, there are plans to add hidden fields in debug modes to enable more safety checks.
If you need a defined layout, use a packed or extern type.
4 Likes