max_align_t
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <stddef.h> で定義
|
||
typedef /*implementation-defined*/ max_align_t; |
(C11以上) | |
std::max_align_t は、少なくともすべてのスカラー型と同じくらい厳しい (大きい) アライメント要件を持つ型です。
ノート
malloc などの確保関数によって返されるポインタはあらゆるオブジェクトに適したアライメントが行われます。 これは少なくとも max_align_t と同じくらい厳しくアライメントされるという意味です。
max_align_t は通常、最も大きなスカラー型の同義語です。 これは多くのプラットフォームでは long double であり、そのアライメント要件は8か16のいずれかです。
例
Run this code
#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);
void *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++リファレンス
|