1

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?

Community
  • 1
  • 1
riveri
  • 27
  • 1
  • 8
  • like I said this was running in linux and win32 and for what I found, this was also causing me a lot of trouble: "First, the ordering of bits in memory is CPU dependent and memory padding rules can vary between compilers" – riveri Jul 26 '11 at 00:53

2 Answers2

1

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

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
0

Here's about the C Bit fields.

littleadv
  • 20,100
  • 2
  • 36
  • 50