C <stddef.h> - max_align_t Type
The C <stddef.h> max_align_t is a type whose alignment requirement is at strict (as large) as that of any possible scalar type, and whose alignment requirement is supported in every context.
max_align_t is usually synonymous with the largest scalar type, which is long double on most platforms, and its alignment requirement is either 8 or 16.
Pointers returned by allocation functions such as malloc() are suitably aligned for any object, which means they are aligned at least as strictly as max_align_t.
In the <stddef.h> header file, it is defined as follows:
typedef /* implementation-defined */ max_align_t;
Example:
In the example below shows how to get the alignment requirement of a given platform.
#include <stdio.h> #include <stddef.h> #include <stdalign.h> int main() { size_t x = alignof(max_align_t); printf("Alignment of max_align_t is: %zu", x); return 0; }
The output of the above code will be:
Alignment of max_align_t is: 16
❮ C <stddef.h> Library