News for hackers. Stuff that matters.
Re:A Better Way to Implement Bit Fields by rwmj on Thursday November 15, 2018 @06:12AM (#18458403)
I wrote ocaml-bitstring (based on Erlang) and it also works by generating the code to handle the bits at compile time. It's fully general too - eg. if you describe a structure of 1 bit followed by an array of bytes then it will add the necessary bit shifts automatically when reading the bytes. Or if you describe a struct where everything is aligned then at compile time it will generate the most efficient code. You can even have variable length bitfields (a huge headache when implementing, but it does deliver the best possible code based on what it can prove at compile time).

[1] https://rwmj.wordpress.com/2010/02/03/on-the-awesomeness-of-...

There are no comments on this comment yet.