* m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER):
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Nov 2006 17:20:07 +0000 (17:20 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Nov 2006 17:20:07 +0000 (17:20 +0000)
Mention that offsetof should be used instead of sizeof.
From Bruno Haible.

ChangeLog
m4/flexmember.m4

index adf5c47f64d1fb6a8c7eae17680d65ab909853cc..58a0ced59531b59aaa2c31ef2a02d7ffa432a161 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 2a6ae474ec2d6b1696065d5aa827d53c318fd69c..bedb799b9cd8881670e451a9d9656e21ee282a41 100644 (file)
@@ -41,7 +41,11 @@ AC_DEFUN([AC_C_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
-       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