开发者

What does ': number' after a struct field mean? [duplicate]

开发者 https://www.devze.com 2023-01-03 11:12 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: What does ‘unsigned temp:3’ means
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

What does ‘unsigned temp:3’ means

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

 unsigned long byt开发者_Python百科e_count  : 32
 unsigned long byte_count2 : 28

What does the : mean here?


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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消