On AIX 7.2 with xlclang, I see this compilation error: xlclang -q64 -qthreaded -qtls -std=gnu11 -DHAVE_CONFIG_H -I. -I../../gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/home/haible/prefix64/include -Wno-error -g -O2 -MT test-alignasof.o -MD -MP -MF .deps/test-alignasof.Tpo -c -o test-alignasof.o ../../gltests/test-alignasof.c In file included from ../../gltests/test-alignasof.c:21: In file included from ../gllib/stddef.h:79: In file included from /opt/IBM/xlC/16.1.0/include2/stddef.h:118: /opt/IBM/xlC/16.1.0/include2/__stddef_max_align_t.h:40:3: error: typedef redefinition with different types ('struct max_align_t' vs 'long') } max_align_t; ^ ../gllib/stddef.h:70:14: note: previous definition is here typedef long max_align_t; ^ 1 error generated.
The reason is that after gnulib's definition of max_align_t, the xlc header files attempt to define max_align_t too. This is done in a separate header file __stddef_max_align_t.h, which is guarded by a '#ifndef __CLANG_MAX_ALIGN_T_DEFINED'. This patch makes things work. 2023-03-16 Bruno Haible <br...@clisp.org> stddef: Fix a compilation error on AIX 7.2 with xlclang. * lib/stddef.in.h (__CLANG_MAX_ALIGN_T_DEFINED): Define whenever we define GNULIB_defined_max_align_t. diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 9e9d4b7cc6..c7ce608b98 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -69,6 +69,7 @@ typedef long rpl_max_align_t; typedef long max_align_t; # define _MAX_ALIGN_T # endif +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif @@ -137,6 +138,7 @@ typedef union long int __i _GL_STDDEF_ALIGNAS (long int); } rpl_max_align_t; # define max_align_t rpl_max_align_t +# define __CLANG_MAX_ALIGN_T_DEFINED # define GNULIB_defined_max_align_t 1 # endif # endif