Alignment
Memory alignment is the requirement that data be placed at an address satisfying the boundary constraints of its type or target architecture.
Modern C, Third Edition
Alignment is the implementation-defined requirement that an object or structure member begin at an address suitable for its type.
- How it is used
- Explains suitable object addresses in the C memory model and their role in structure layout and pointer conversions.
- How deep it goes
- Defines type alignment and demonstrates misaligned access with byte-offset pointer casts and a bus-error example.
- Examples
- Uses padded structure members and a byte-buffer overlay of complex values tested at progressively smaller offsets.
- What you can do after
- Diagnose misaligned pointer conversions by examining byte offsets and their effects on typed access.
Modern C
Alignment is the requirement that an object be stored at an address suitable for its type's access constraints.
- How it is used
- Constrains pointer-based access to objects within the C memory and object model.
- How deep it goes
- Defines permissible starting positions, demonstrates a crashing misaligned access, and stops short of broader hardware implementation details.
- Examples
- Demonstrates a complex double and byte-buffer union tested at offsets 16, 8, 4, 2, and 1.
- What you can do after
- Diagnose misaligned pointer access and request suitable storage alignment with alignas.
Related concepts
- alignasconfigured by · alignas, also spelled _Alignas, is an alignment specifier that requests a specified alignment for an object or declaration.
- paddingproduces · Padding is the addition or insertion of extra space, values, or data into or around a structure or input to meet a specified size, boundary, alignment, or processing requirement.
- vectorizationused by · Vectorization is the representation of data or computations as vectors or arrays so they can be processed numerically or collectively.
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.

