Sergei on Tech

eInsights and then some

Sergei on Tech header image 4

Entries Tagged as 'C'

Bit Fields, what are those?

April 5th, 2008 · No Comments

I was working on some C code today and ran into something I wasn’t familiar with:

typedef struct {
uint8_t h:4;
uint8_t n:4;
} Buf;
What do those colons mean?

Bit Fields allow the packing of data in a structure. This is especially useful when memory or data storage is at a premium. Typical examples:
* Packing several objects […]

[Read more →]

Tags: C