Machine-translated by Google. Questions are authored in English.
Top

Discussion

Bit fields in a structure are of limited portability because the standard leaves

  • A.the allocation order within the storage unit unspecified
  • B.the width of each field to the compiler
  • C.their type always signed regardless of the declaration
  • D.them without any storage at all until assigned

Answer: A

Whether the first declared field occupies the low or the high bits, and how fields straddle a unit boundary, are implementation defined, so the same declaration maps differently on two compilers. Masks and shifts on an explicit unsigned type are portable where bit fields are not.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.