changeset 27308:07b3f42def3c

* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): Mention that offsetof should be used instead of sizeof. From Bruno Haible.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 07 Nov 2006 17:20:07 +0000
parents f68806b63db7
children 43a11ebbec31
files ChangeLog m4/flexmember.m4
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Nov 07 14:57:19 2006 +0000
+++ b/ChangeLog	Tue Nov 07 17:20:07 2006 +0000
@@ -1,3 +1,9 @@
+2006-11-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
+	Mention that offsetof should be used instead of sizeof.
+	From Bruno Haible.
+
 2006-11-07  Bruno Haible  <bruno@clisp.org>
 
 	* lib/w32spawn.h (prepare_spawn): Use XNMALLOC instead of xmalloc.
--- a/m4/flexmember.m4	Tue Nov 07 14:57:19 2006 +0000
+++ b/m4/flexmember.m4	Tue Nov 07 17:20:07 2006 +0000
@@ -41,7 +41,11 @@
       [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.])
+       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