<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div>Hi Dan,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">So I have a use for a struct with 4 single-bit members.</div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">currently vx3 (And others) have a separate structure that contains some bitmask fields for various flags.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">They are only 4 bits per channel. However, due to bitwise constraints, it seems we are left with doing something like:</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console',
sans-serif; background-color: transparent; font-style: normal;">struct {</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> u8 odd_flagA:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> odd_flagB:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> odd_flagC:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> odd_flagD:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> even_flagA:1,</div><div
style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> even_flagB:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> even_flagC:1,</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> even_flagD:1;</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">} flags [50];</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color:
transparent; font-style: normal;">and then using some unholy trickery to interleave this out where we need it - it's very ugly, and confusing.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">What I'd like to do is take advantage of the simple "bit" type in bitwise.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">So I thought i'd simplify the above to:</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">struct {</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console',
sans-serif; background-color: transparent; font-style: normal;"> bit flagA;</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> bit flagB;</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> bit flagC;</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"> bit flagD;</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">} flags [100];</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px;
font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">But when I do this bitwise.py croaks with <span style="font-size: 10pt;">"bit array must be divisible by 8." (trace below).</span></div><div style="color: rgb(0, 0, 0); font-size: 10pt; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><span style="font-size: 10pt;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><span style="font-size: 10pt;">Why is it this way? The second form would be much simpler and cleaner overall in the code to work with.</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">Is there some alignment concern? Is there any provision for a data type of less than a
byte?</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/vx3.py", line 372, in process_mmap</div><div style="background-color: transparent;"> self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)</div><div style="background-color: transparent;"> File
"/Users/jens/build/chirp.hg/chirp/bitwise.py", line 857, in parse</div><div style="background-color: transparent;"> return p.parse(ast)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 850, in parse</div><div style="background-color: transparent;"> self.parse_block(lang)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 841, in parse_block</div><div style="background-color: transparent;"> self.parse_struct(d)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 822, in parse_struct</div><div style="background-color: transparent;"> return self.parse_struct_decl(struct[0][1])</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 805, in
parse_struct_decl</div><div style="background-color: transparent;"> self.parse_block(block)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 843, in parse_block</div><div style="background-color: transparent;"> self.parse_defn(d)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 773, in parse_defn</div><div style="background-color: transparent;"> gen = self.do_bitarray(i, count)</div><div style="background-color: transparent;"> File "/Users/jens/build/chirp.hg/chirp/bitwise.py", line 745, in do_bitarray</div><div style="background-color: transparent;"> raise ValueError("bit array must be divisible by 8.")</div></div></body></html>