From 240cbc9e31fbe7ac0a9f1921b162486ffc30659e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 25 Sep 2022 00:23:20 +0200 Subject: [PATCH] stdalign: Avoid namespace pollution. * lib/stdalign.in.h (_GL_STDALIGN_NEEDS_STDDEF): New macro. Include only when needed. --- ChangeLog | 6 ++++++ lib/stdalign.in.h | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b5804df68..b0223bba7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-09-24 Bruno Haible + + stdalign: Avoid namespace pollution. + * lib/stdalign.in.h (_GL_STDALIGN_NEEDS_STDDEF): New macro. + Include only when needed. + 2022-09-23 Simon Josefsson warnings, manywarnings: Doc fixes. diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index 3b117df11f..9ba40e2c45 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h @@ -42,10 +42,7 @@ '-malign-double' is used. The result cannot be used as a value for an 'enum' constant, if you - want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. - - Include for offsetof. */ -#include + want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ /* FreeBSD 9.1 , included by and lots of other standard headers, defines conflicting implementations of _Alignas @@ -66,9 +63,11 @@ # else template struct __alignof_helper { char __a; __t __b; }; # define _Alignof(type) offsetof (__alignof_helper, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # else # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 # endif #endif #if ! (defined __cplusplus && 201103 <= __cplusplus) @@ -124,4 +123,9 @@ # define __alignas_is_defined 1 #endif +/* Include if needed for offsetof. */ +#if _GL_STDALIGN_NEEDS_STDDEF +# include +#endif + #endif /* _GL_STDALIGN_H */ -- 2.39.5