I know this is a bit cursed; but, I always wanted a bitfield-on-steroids construct:
struct Dang : bits 64 // 64 bits wide, int total
{
foo : bits 5 @ 0; // 5 bits wide at bit offset 0
bar : bits 5 @ 0;
baz : bits 16 @ 4; // 16 bits wide at bit offset 4
tom : bits 11 @ 32;
};I think you can do this with Virgil, but I'm having trouble finding the exact doc page at the moment: https://github.com/titzer/virgil
You can kinda do this with Zig’s packed structs and arbitrary-width integers
Are you saying you want foo and bar to completely overlap? And baz and foo / bar to partially overlap? And have lots of unused bits in there too?