Bruno Haible <[EMAIL PROTECTED]> wrote: > Simon Josefsson wrote: >> > you don't need it, >> > because the rules for struct layout in C guarantee that a structure field >> > is aligned to a multiple of the alignment of the previous field. >> >> Are you saying that even if we don't change the type of buffer to >> char, we don't need that alignment? I would agree, but I'm not >> certain. > > If the previous struct element is a 'uint32_t' then a struct element of > type char or char[] has the same alignment. You can rely on it, but it > deserves a comment because it would break if someone inserts, say, a > 'short' field in between.
Comment-only requirements can be overlooked. Putting a compile-time assertion like the following, right after the struct definition, adds some clout :-) verify (offsetof (struct S, member_m) % 4 == 0); Hmm... that assumes 8-bit bytes. Does anyone know of existing systems, less than say 10 years old that have CHAR_BIT different from 8? _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib