* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): Improve comment. --- ChangeLog | 5 +++++ m4/flexmember.m4 | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 0c4c515a0..efa81e2ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-05-24 Paul Eggert <egg...@cs.ucla.edu> + + flexmember: update comment + * m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): Improve comment. + 2019-05-20 Bruno Haible <br...@clisp.org> setlocale: Improve fallback on macOS. diff --git a/m4/flexmember.m4 b/m4/flexmember.m4 index 1347068fe..ef6373df2 100644 --- a/m4/flexmember.m4 +++ b/m4/flexmember.m4 @@ -34,10 +34,14 @@ AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER], AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], [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 + { int n; char 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. + Use 'FLEXSIZEOF (struct s, d, N)' to calculate the size in bytes + of such a struct containing an N-element array, as both + 'sizeof (struct s) + N * sizeof (char)' and + 'offsetof (struct s, d) + N * sizeof (char)' + might compute a size that can cause malloc to align storage + improperly, even in C11. Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with MSVC and with C++ compilers.]) else -- 2.21.0