c/c++单冒号
可能的重复:
“unsigned temp:3”是什么意思
我是 c/c++ 的新手我在 linux 和 win32 上运行了这段代码
typedef struct tMessageAction
{
unsigned char ActionId : 4;
unsigned short ID : 10;
}tMessageAction;
,那么单冒号对这个变量做了什么? 他们是否指定将使用多少位? 这与某种类型的结构对齐属性有关吗?
Possible Duplicate:
What does 'unsigned temp:3' means
I'm a newbie to c/c++ and I have this code running on linux and win32
typedef struct tMessageAction
{
unsigned char ActionId : 4;
unsigned short ID : 10;
}tMessageAction;
so what are the single colons doing to this variables?
are they specifying how many bits are going to be used?
is this related to some type of structure alignment attribute?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
冒号定义位字段。它们不会改变对齐规则。
The colons are defining a bitfield. They do not change the alignment rules.
以下是关于 C 位字段的信息。
Here's about the C Bit fields.