4 ms·
I've only used bitfields for register access. I get the first 3 points you make. (I use uint32_t for all fields) What is the danger in #4 if you've followed #1
by eecsninja 8y ago
I've only used bitfields for register access. I get the first 3 points you make. (I use uint32_t for all fields) What is the danger in #4 if you've followed #1-3?
You seem overly paranoid. Is there something from your experience that makes you nervous about bitfields?
- jcranmer 8y agoI work on compilers for a living, which means I have a first-hand impression of the fallout of "the semantics seem clear until you actually think about all of the corner cases." I also have an appreciation for compilers blindly doing the wrong thing when you start mixing weird constructs together, and bitfields are very much a weird construct. The last rule is a recognition that bitfields are weird constructs, and their interactions with other weird constructs are likely to cause problems. One example: try using a bitfield in a ternary lvalue operation, especially with clang.