型属性 aligned

Linux 型属性 aligned を使用すると、構造体、クラス、共用体、または列挙型の位置合わせを指定することができます。 指定する位置合わせ係数の構文および考慮事項は、 変数属性 aligned と同じです。変数属性 aligned と同様に、型属性 aligned は位置合わせを増加させるだけです。 型属性 packed は、位置合わせを減少させるために使用します。

属性が、クラス、構造体、共用体、または列挙型トークンの直後、 または右中括弧の直後に表示される場合、型 ID に適用されます。typedef 宣言で指定することもできます。 以下のような変数宣言では、

class A {} a;

型属性の配置が混乱する可能性があります。

次の定義で、属性は A に適用されます。

struct __attribute__((__aligned__(8))) A {};
struct A {} __attribute__((__aligned__(8))) ;
struct __attribute__((__aligned__(8))) A {} a;
struct A {} __attribute__((__aligned__(8))) a;
 
typedef struct __attribute__((__aligned__(8))) A {} a;
typedef struct A {} __attribute__((__aligned__(8))) a;

次の定義で、属性は a に適用されます。

__attribute__((__aligned__(8))) struct A {} a;
struct A {} const __attribute__((__aligned__(8))) a;
 
__attribute__((__aligned__(8))) typedef struct A {} a;
typedef __attribute__((__aligned__(8))) struct A {} a;
typedef struct A {} const __attribute__((__aligned__(8))) a;
typedef struct A {} a __attribute__((__aligned__(8)));

関連参照

IBM Copyright 2003