©
This document uses PHP Chinese website manual Release
在头文件<stddef.h>中定义 | ||
---|---|---|
typedef / *实现定义* / max_align_t; | (自C11以来) |
max_align_t
是一种对齐要求至少与每个标量类型一样严格(大)的类型。
由malloc等分配函数返回的指针适合任何对象对齐,这意味着它们的对齐方式至少与max_align_t一样严格。
max_align_t通常是最大标量类型的同义词,在大多数平台上它是长双倍的,并且其对齐要求为8或16。
#include <stdio.h>#include <stddef.h>#include <stdalign.h>#include <stdlib.h>#include <stdint.h>#include <inttypes.h> int main(void){ size_t a = alignof(max_align_t); printf("Alignment of max_align_t is %zu (%#zx)\n", a, a); int *p = malloc(123); printf("The address obtained from malloc(123) is %#" PRIxPTR"\n", (uintptr_t)p); free(p);}
可能的输出:
Alignment of max_align_t is 16 (0x10)The address obtained from malloc(123) is 0x1fa67010
| 用于max_align_t的C ++文档|