Open nick-hunter opened 1 year ago
Yes, this is by design and we should document it. Basically, anything except bit fields needs to be byte-aligned. This is to simplify the parser builder code (otherwise we would need to keep track of bit and byte positions as you mentioned).
I'm currently writing an application that creates several hundred different parsers based on structures defined in a database. I have a lookup table that converts the datatype from the DB into a type from
binary-parser
. I discovered a difference betweenbit8
anduint8
and I'm wondering if this is expected behavior or not.Here is the generated code for both parsers
The code for p1 reads one bit, skips 7 bits, and starts reading at the start of the next byte. Is this expected? I didn't see anything in the docs about this difference. I'm thinking about tracking both the bit and byte position, and rewriting uint8 to bit8 if the bit offset != 0. Just wanted to see if anyone else has run into similar issues.