Paul Eggert wrote: > * modules/flexmember, m4/flexmember.m4: New files.
Nice. Maybe add a reference to ISO C99 6.7.2.1.(16) ? Also, a little bit of methodology explanation would be nice, for those who would naively want to use sizeof on such a type. *** gnulib-20061106/m4/flexmember.m4 2006-11-06 22:58:29.000000000 +0100 --- gnulib-20061106-modified/m4/flexmember.m4 2006-11-07 02:12:12.000000000 +0100 *************** *** 41,47 **** [Define to nothing if C supports flexible array members, and to 1 if it does not. That way, with a declaration like `struct s { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack ! can be used with pre-C99 compilers.]) else AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1) fi --- 41,51 ---- [Define to nothing if C supports flexible array members, and to 1 if it does not. That way, with a declaration like `struct s { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack ! can be used with pre-C99 compilers. ! When computing the size of such an object, don't use 'sizeof (struct s)' ! as it overestimates the size. Use 'offsetof (struct s, d)' instead. ! Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with ! MSVC and with C++ compilers.]) else AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1) fi