liveBook · Manning

Bit field

A bit field is a designated group of bits within a value or storage unit that represents a data component.

How 2 Manning books explain it

Refactoring to Rust

A bitfield is a structure field occupying a specified number of individual bits rather than a whole storage unit.

How it is used
Uses bit fields when configuring NGINX response buffers through Rust foreign-function interfaces.
How deep it goes
Defines bit fields and demonstrates generated accessors, stopping short of implementing native Rust bit-field support.
Examples
Demonstrates memory, last_buf, and last_in_chain as one-bit fields on ngx_buf_t.
What you can do after
Operate NGINX bit-field flags through bindgen-generated setter functions.

Read how Refactoring to Rust explains bit field →

Modern C, Third Edition

A bit-field is a C structure or union member declared with a specified number of bits rather than a complete storage-unit width.

How it is used
Uses bit fields to reduce structure storage when values need fewer bits than their declared integer types.
How deep it goes
Explains declaration syntax, compiler coalescing, member access, storage estimates, and signedness hazards, but not complete layout rules.
Examples
Uses calendar-style fields for seconds, minutes, hours, dates, weekdays, year, and daylight-saving status.
What you can do after
Build it from scratch by declaring compact C structure fields, accessing them normally, and checking signedness choices.

Read how Modern C, Third Edition explains bit field →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.