Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This compliant solution uses an unsigned int bit-field and does not depend on implementation-defined behavior.:

Code Block
bgColor#ccccff
langc
struct {
  unsigned int a: 8;
} bits = {255};

int main(void) {
  printf("bits.a = %d.\n", bits.a);
  return 0;
}

...

Bibliography

[ISO/IEC 9899:2011]Section 6.3.1.1, "Boolean, Characters, and Integers"

...