What does the : do in a struct declaration after a member

后端 未结 1 898
时光取名叫无心
时光取名叫无心 2020-12-22 01:05

In:

struct foo {
  unsigned bar : 2;
};

What does the \': 2\' do?

相关标签:
1条回答
  • 2020-12-22 01:16

    It declares a bit field. The number specifies the size of that member in bits.

    0 讨论(0)
提交回复
热议问题