「C言語/標準ライブラリ/stdalign.h」の版間の差分

削除された内容 追加された内容
Ef3 (トーク | 投稿記録)
初稿
タグ: 2017年版ソースエディター
 
Ef3 (トーク | 投稿記録)
{{Nav}}
タグ: 2017年版ソースエディター
1 行
{{Nav}}
オブジェクトのアライメントの問い合わせと指定をするためには、ヘッダー<code><stdalign.h></code> をインクルードします<ref name="jtc1-sc22-wg14-n1570-7.15">{{cite book | url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf | title= C11: WG14/N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x | at=p.268, §7.15 ''Alignment <stdalign.h>'' | publisher=ISO/IEC}}</ref>。
 
オブジェクトのアライメントの問い合わせと指定をするためには、ヘッダー<code><stdalign.h></code> をインクルードします<ref name="jtc1-sc22-wg14-n1570-7.15">{{cite book | url=http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf | title= C11: WG14/N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x | at=p.268, §7.15 ''Alignment <stdalign.h>'' | publisher=ISO/IEC}}</ref>。
 
== マクロ ==
6 ⟶ 7行目:
 
; alignas
: キーワード <code>_Alignas</code> に展開されます。
; alignof
: キーワード <code>_Alignof</code> に展開されます。
; _alignas_is_defined
: 整数の定数1に展開されます。
20 ⟶ 21行目:
; 例
:<syntaxhighlight lang=c>
#include <stdio.h>
#include <stdalign.h>
#include <stdio.h>
 
int main(void) {
{
alignas(65536) int i;
alignas(256) int j;
46 行
; 例
:<syntaxhighlight lang=c>
#include <stdio.h>
#include <stdalign.h>
#include <stdio.h>
 
int main(void) {
printf("doublecharのアラインメント要件は%zu。\n", alignof(doublechar));
{
printf("charintのアラインメント要件は%zu。\n", alignof(charint));
printf("intfloatのアラインメント要件は%zu。\n", alignof(intfloat));
printf("floatdoubleのアラインメント要件は%zu。\n", alignof(floatdouble));
return 0;
printf("doubleのアラインメント要件は%zu。\n", alignof(double));
return 0;
}
</syntaxhighlight>
65 ⟶ 64行目:
doubleのアラインメント要件は8。
</syntaxhighlight>
 
 
== 歴史 ==
alignas型指定子(キーワード_Alignas)、alignof演算子(キーワード_Alignof)、ヘッダー<code><stdalign.h></code>、ISO/IEC 9899:2011で追加されました<ref name="jtc1-sc22-wg14-n1570-7.15" />。
 
 
== 脚註 ==
<references />
 
 
== 関連項目 ==
* [[C++/キーワード]] -- alignas と alignofは、[[C++]]のキーワードです。
* [[C言語/標準ライブラリ/一般ユーティリティ#aligned alloc関数|C言語/標準ライブラリ/一般ユーティリティ#aligned_alloc関数]] -- <code>aligned_alloc</code>はアライメント関連ですが、ヘッダー<code><stdlib.h></code>で宣言されます。
 
 
== 参考文献 ==