これは C99 コードです:
typedef struct expr_t
{
int n_children;
foo data; // Maybe whatever type with unknown alignment
struct expr_t *children[];
} expr_t;
さて、どのようにメモリを割り当てますか?
expr_t *e = malloc (sizeof (expr_t) + n * sizeof (expr_t *));
また
expr_t *e = malloc (offsetof (expr_t, children) + n * sizeof (expr_t *));
?
柔軟な配列メンバーを持つ型で動作することがsizeof
保証されていますか (GCC はそれを受け入れます) ?