zig icon indicating copy to clipboard operation
zig copied to clipboard

std.meta: Add `LittleEndianLayout(T)` and `Stage1Layout(T)`

Open topolarity opened this issue 3 years ago • 0 comments

These are small helpers that re-order the fields of a packed struct to provide either:

  • Stage1Layout(T)
    • Layout compatibility with stage1, a temporary helper until users can re-define their packed structs appropriately
  • LittleEndianLayout(T)
    • Guaranteed in-memory layout, including for types that are currently unsupported in extern struct (e.g. u1, u24)
    • Supports bit-fields (fields smaller than u8), as long as they do not cross a byte boundary

These might be controversial, but I wanted to open the PR just in case they are helpful (especially to ease the stage1 -> stage2 transition for users)

topolarity avatar Oct 18 '22 22:10 topolarity