C言語なら、俺に聞け! <11>
■ このスレッドは過去ログ倉庫に格納されています
0074デフォルトの名無しさん
NGNGマクロ使うのはOK。
struct a {
int namelen;
char namestr[10];
};
struct b {
int namelen;
char namestr[20];
};
のとき、offsetof(struct a, namestr) == offsetof(struct b, namestr)である
保証がないということ。C99では配列の長さを変数にした場合や省略した場合、
struct c {
int namelen;
char namestr[namelen + 1];
};
struct d {
int namelen;
char namestr[];
};
において、offsetof(struct c, namestr) == offsetof(struct d, namestr)となる
ことが保証されてる。
■ このスレッドは過去ログ倉庫に格納されています