bitmap - Bit alignment, 8-bools-in-1 -


i'm trying compile following code:

union bool {   bool b[8] : 8; // (1)   bool b0,b1,b2,b3,b4,b5,b6,b7 : 1; }; 

however line (1) doesn't compile, whats syntax bit aligning array?

you can't declare array of bits in c.

the concept of array based on pointer, , can have pointers bytes, not individual bits within byte. c bit fields allow pack integer components less memory compiler default. array isn't integer, can't pack array bit field. if want read on standard, can find @ iso/iec 9899 - programming languages - c (look §6.7.2.1).

if need speed, use union of array of bools, , if need compact memory footprint, define macros provide more convenient access bit fields.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -