Junsuke Kunugiza さんは書きました: >仮に「宣言の順番通りになる」という保証があるとすれば、その >根拠に絶大な興味がありますね。境界の関係などでパディングが >前後中間に挿入され、実際にどうメモリに配置されるかは不定で >あるにも関わらず、構造体メンバが配置される順序を決めておか >なければ都合が悪いと結論するに十分合理的な理由が思い当たら >ないのです。 > パディングは後と中間には入ることがありますが、前には入りません。 隙間ができないようにメンバを並べるのは、コンパイラの仕事ではなくプログラムを書く人間がする仕事です。 >ひょっとすると、堂々と規定されていることかも知れないので、 >ここまで書いてやや不安になってきましたが(^^; 外していたら >お詫びします。 > 今年の初めのC9xのドラフトから引用(たぶんC89も同じことが書かれていると思います) Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably converted, points to its initial member (or if that member is a bit-field, then to the unit in which it resides), and vice versa. There may be unnamed padding within a structure object, but not at its beginning. ---- 岩本 秀樹 h-iwamoto@xxxxxxxxxxxxxx