TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
_Alignof operator is a unary operator introduced in C11 that evaluates to the alignment requirement of a specified type. It returns the number of bytes representing the boundary on which an object of the given type must be allocated in memory.
Technical Specifications
- Return Type: The operator evaluates to an integer constant expression of type
size_t(defined in<stddef.h>). - Operand: The operand must be a parenthesized type name. Unlike the
sizeofoperator,_Alignofcannot accept an expression as its operand. - Evaluation: The result is determined entirely at compile-time.
Type-Specific Behavior
- Scalar Types: Returns the architecture-specific alignment boundary for the type (e.g.,
_Alignof(int)typically returns4). - Array Types: When applied to an array type,
_Alignofevaluates to the alignment requirement of the array’s underlying element type, not the alignment of the entire array block. - Struct and Union Types: When applied to a
structorunion, it evaluates to the strictest (largest) alignment requirement among all of its members.
Constraints and Restrictions
The_Alignof operator will result in a compilation error if applied to:
- Function types.
- Incomplete types (such as forward-declared structs without a defined body).
- The
voidtype.
Standard Library Integration
While_Alignof is the native keyword, the C standard library provides a convenience macro in the <stdalign.h> header:
alignof becomes a native keyword, making the inclusion of <stdalign.h> obsolete for this purpose, though _Alignof remains valid for backward compatibility.
Syntax Visualization
Master C with Deep Grasping Methodology!Learn More





