开发者

c/c++ single colon [duplicate]

开发者 https://www.devze.com 2023-03-22 17:01 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: What does '开发者_开发问答;unsigned temp:3' means
This question already has answers here: Closed 11 years ago.

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?


The colons are defining a bitfield. They do not change the alignment rules.


Here's about the C Bit fields.

0

精彩评论

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

关注公众号