summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-05-24 14:59:11 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-05-24 15:01:20 -0700
commit0ffb8fd223dbc9ab6ec8aa33fb1cdf1056856344 (patch)
treea77b573066a08ed96415ded3185a062ec5aa711a /m4
parent34d712407676b159bd72b79bedb3ddd788adb28d (diff)
downloadgnulib-0ffb8fd223dbc9ab6ec8aa33fb1cdf1056856344.tar.gz
flexmember: update comment
* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): Improve comment.
Diffstat (limited to 'm4')
-rw-r--r--m4/flexmember.m410
1 files changed, 7 insertions, 3 deletions
diff --git a/m4/flexmember.m4 b/m4/flexmember.m4
index 1347068fe3..ef6373df29 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