Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3.5: bitfields and basic types
#4
Reggi Wrote:why i should write

unsigned int x_set:1

and not

uint32_t x_set:1? When uint32_t is a typedef unsigned int uint32_t; on a 32 bit architecture,
or
uint16_t x_set:1 When uint16_t is a typedef unsigned int uint16_t on a 16 bit architecture ??

What would the purpose of this be? The point of the "sized types" is that they offer some measure of platform portability. Here you are using them to decrease portability -- you'll need to ensure that your bit-field is declared with the type that matches int on your platform. If you want an unsigned bit field then "unsigned" is the word to use.

stephen


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)