]> Savannah Git Hosting - gnulib.git/commitdiff
flexmember: port to IBM XL C 16.1
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Jan 2025 07:02:09 +0000 (23:02 -0800)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Feb 2025 09:56:03 +0000 (10:56 +0100)
* lib/flexmember.h (FLEXALIGNOF): Use the conservative definition
if _Alignof is a macro, to avoid a C99 conformance issue exposed
by IBM XL C 16.1 which otherwise complains "An aggregate
containing a flexible array member cannot be used as a member of a
structure or as an array element."

ChangeLog
lib/flexmember.h

index 55e4b6db6617eba1025e393f69d4d342f81b5771..ed63398f8cc738445c72ca17461f46c4ca017e86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-01-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       flexmember: port to IBM XL C 16.1
+       * lib/flexmember.h (FLEXALIGNOF): Use the conservative definition
+       if _Alignof is a macro, to avoid a C99 conformance issue exposed
+       by IBM XL C 16.1 which otherwise complains "An aggregate
+       containing a flexible array member cannot be used as a member of a
+       structure or as an array element."
+
 2025-01-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        alignasof: port to IBM XL C 16.1
index 6ef66a32d3227e89fc65388bb96c14606b7ae0d8..b4d86c29fb5496a9ed3bd87c2d56cf42265e4194 100644 (file)
@@ -1,6 +1,6 @@
 /* Sizes of structs with flexible array members.
 
-   Copyright 2016-2024 Free Software Foundation, Inc.
+   Copyright 2016-2025 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
 
 #include <stddef.h>
 
 /* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
-   On older platforms without _Alignof, use a pessimistic bound that is
+   If _Alignof might not exist or might not work correctly on
+   structs with flexible array members, use a pessimistic bound that is
    safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
-   On newer platforms, use _Alignof to get a tighter bound.  */
+   Otherwise, use _Alignof to get a tighter bound.  */
 
-#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 || defined _Alignof
 # define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
 #else
 # define FLEXALIGNOF(type) _Alignof (type)