0

Possible Duplicate:
What does ‘unsigned temp:3’ means

I came across some code like this that I am not sure with:

 unsigned long byte_count  : 32
 unsigned long byte_count2 : 28

What does the : mean here?

Community
  • 1
  • 1
lukmac
  • 191
  • 1
  • 2
  • 9

2 Answers2

12

That is a bit field:

a data structure used in computer programming. It consists of a number of adjacent computer memory locations which have been allocated to hold a sequence of bits, stored so that any single bit or group of bits within the set can be addressed. A bit field is most commonly used to represent integral types of known, fixed bit-width...

gnat
  • 6,213
  • 108
  • 53
  • 73
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
-1

It's also non-standard. Bit fields must be of type _Bool (C99), signed int or unsigned int. However, GCC allows any integer type. The type affects the alignment of the field, the alignment of any subsequent field, and the overall size of the struct containing the bit-field.

John
  • 259
  • 1
  • 2