On Tuesday, 17 June 2014 at 13:07:33 UTC, Marc Schütz wrote:
On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote:
This one depends on taste, but these helpers can be eliminated by changing the Header definition a little. It's the same union / anonymous struct trick from the previous post, only this time with bitfields:

http://dpaste.dzfl.pl/13258b0ce0c4

If you define nested structs/unions, it's better to make them static whenever possible, because non-static nested structs have an additional hidden field for the context.

Good call. In this case it doesn't add the hidden field, but for the sake of consistency I agree it's better to add static.

Also, when you work with bit-(un)packing, you need to make sure it works on big- and little-endian CPUs.

Yeah. He's using a custom read function that takes endianness into account, so I didn't mention it.

Reply via email to