Question: I see in some C++ code things like:

```
// Header
struct SomeStruct {
    uint32_t nibble1:4, bitField1:1, bitField2:1, bitField3:1, bitField4:1,
             padding:11, field5Bits:5, byteField:8;
};

```

What is this called? I typically like to google before asking here, but I have no idea what to even type in. I'm hoping to understand this when it comes to endianness - is bit order something to consider or just byte order? Also, what is the type of each field - bitFieldX should be a bool, while field5Bits should be a uint8\_t. At least that's what I would think.

Thanks.

Answer: 
1. They are called bitfields ([MSVC](http://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx)) ([GCC](http://gcc.gnu.org/onlinedocs/gccint/Bit_002dFields.html))
2. Endianess usually refers to the order of bytes. However bit order can be important, see the above links.
3. They behave as an unsigned int (uint32\_t) in your case.
What you posted is a packed structure. The elements within the structure are know as bitfields as others have posted. These are often used to represent communication protocol structures, where the protocol specifies fields that are less than one byte, or not aligned to a byte, half-word or word alignment that would normally take place.

Since there is only one type listed, each member of the structure is the same type, uint\_32.

Endianess does matter for anthing that is part of a data type that is larger than 1 byte.