?
This document uses PHP Chinese website manual Release
在頭文件<stddef.h>中定義 | ||
---|---|---|
typedef / *實(shí)現(xiàn)定義* / max_align_t; | (自C11以來(lái)) |
max_align_t
是一種對(duì)齊要求至少與每個(gè)標(biāo)量類(lèi)型一樣嚴(yán)格(大)的類(lèi)型。
由malloc等分配函數(shù)返回的指針適合任何對(duì)象對(duì)齊,這意味著它們的對(duì)齊方式至少與max_align_t一樣嚴(yán)格。
max_align_t通常是最大標(biāo)量類(lèi)型的同義詞,在大多數(shù)平臺(tái)上它是長(zhǎng)雙倍的,并且其對(duì)齊要求為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 ++文檔|