From 16c580bd609546aed1110ccade82afb3579688d5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 18 Jan 2025 23:02:09 -0800 Subject: [PATCH] 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." --- ChangeLog | 9 +++++++++ lib/flexmember.h | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e86d07f8f..7af1c0bfe4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-01-18 Paul Eggert + + 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 alignasof: port to IBM XL C 16.1 diff --git a/lib/flexmember.h b/lib/flexmember.h index 15ee4f5e28..b4d86c29fb 100644 --- a/lib/flexmember.h +++ b/lib/flexmember.h @@ -28,11 +28,12 @@ #include /* 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) -- 2.39.5