a type issue in the framework

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

just wondering if theing type "unsigned int" to represent pin number in GPIO driver is good?

cuz I think "unsigned int" can be either 2 or 4 bytes, right? so why not using "unsigned short" which is always 2 bytes?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

{unsigned,} int is usually good practise as it's the native width of the processor and tends to be delt with more efficiently. It shouldn't magically change it's storage size (or does GCC make assumptions about storage type sizes and optimize it all down?). I know at least using the avr32-linux- toolchain int is 32-bit. You're quite right though, for the space concious it could quite easily be unsigned short or better than that, an explicitly sized type, eg uint16_t/u16/__u16 depending which one(s) are implemented.

-S.