[PATCH 1/3] Document max_align_t
Paul Eggert
eggert@cs.ucla.edu
Fri Feb 6 08:22:42 GMT 2026
* manual/lang.texi (Important Data Types): Mention max_align_t.
---
manual/lang.texi | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/manual/lang.texi b/manual/lang.texi
index cd90ff60d2..b985cf4561 100644
--- a/manual/lang.texi
+++ b/manual/lang.texi
@@ -16,7 +16,7 @@ features has been written, we are publishing it here.
* Variadic Functions:: Defining functions with varying numbers
of args.
* Null Pointer Constant:: The macro @code{NULL}.
-* Important Data Types:: Data types for object sizes.
+* Important Data Types:: Types for object sizes and alignments.
* Data Type Measurements:: Parameters of data type representations.
@end menu
@@ -555,7 +555,8 @@ recommend instead adding a prototype for the function you are calling.
The result of subtracting two pointers in C is always an integer, but the
precise data type varies from C compiler to C compiler. Likewise, the
data type of the result of @code{sizeof} also varies between compilers.
-ISO C defines standard aliases for these two types, so you can refer to
+Also, it is helpful to have a data type with the greatest standard alignment.
+ISO C defines standard aliases for these types, so you can refer to
them in a portable fashion. They are defined in the header file
@file{stddef.h}.
@pindex stddef.h
@@ -583,10 +584,24 @@ will be @w{@code{unsigned int}} or @w{@code{unsigned long int}}.
arguments or variables that hold the size of an object.
@end deftp
+@deftp {Data Type} max_align_t
+@standards{ISO, stddef.h}
+@cindex fundamental alignment
+This is an object type with the greatest @dfn{fundamental alignment},
+i.e., the greatest alignment of all integer, floating, enumerated,
+pointer, and standard library types such as @code{mbstate_t}, along
+with all array, structure, and union types that are composed only of
+these types and that lack stricter alignment specifiers.
+Code can use @code{alignof (max_align_t)} when calculating space
+needed for arbitrary collections of objects, so long as the objects'
+types are fundamental and lack stricter alignment specifiers.
+@end deftp
+
@strong{Compatibility Note:} Implementations of C before the advent of
@w{ISO C} generally used @code{unsigned int} for representing object sizes
and @code{int} for pointer subtraction results. They did not
-necessarily define either @code{size_t} or @code{ptrdiff_t}. Unix
+necessarily have @code{<stddef.h>} or define the types @code{size_t},
+@code{ptrdiff_t}, or @code{max_align_t}. Unix
systems did define @code{size_t}, in @file{sys/types.h}, but the
definition was usually a signed type.
--
2.52.0
More information about the Libc-alpha
mailing list