16 ms·
I pack structs because the packed layout matches some hardware or network structre and thus I get direct access . This isn't a common case but it exists.
by bluGill 1y ago
I pack structs because the packed layout matches some hardware or network structre and thus I get direct access . This isn't a common case but it exists.
- yellowapple 1y agoThat case is much more common in embedded/bare-metal programming. A decent chunk of the code I've written so far for getting Zig running on a Nintendo 64 is a bunch of packed structs representing various registers (and a bunch of methods on those structs representing common uses of those registers). It's also a reasonably common case for parsing binary data formats (e.g. a file's header has fields at exact byte offsets, and it's much faster and easier to just grab all the bytes of that header and interpret those bytes as a packed struct).