]> Savannah Git Hosting - gnulib.git/commitdiff
stdalign: Avoid namespace pollution.
authorBruno Haible <bruno@clisp.org>
Sat, 24 Sep 2022 22:23:20 +0000 (00:23 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 24 Sep 2022 22:23:20 +0000 (00:23 +0200)
* lib/stdalign.in.h (_GL_STDALIGN_NEEDS_STDDEF): New macro.
Include <stddef.h> only when needed.

ChangeLog
lib/stdalign.in.h

index 5b5804df682bfb167c7c2a31cecc0a24142f720f..b0223bba7ec03d888290ab32f86830dfae141c02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-24  Bruno Haible  <bruno@clisp.org>
+
+       stdalign: Avoid namespace pollution.
+       * lib/stdalign.in.h (_GL_STDALIGN_NEEDS_STDDEF): New macro.
+       Include <stddef.h> only when needed.
+
 2022-09-23  Simon Josefsson  <simon@josefsson.org>
 
        warnings, manywarnings: Doc fixes.
index 3b117df11fe25f9985adfa75c9c2850fcb21da2e..9ba40e2c45f9f79fd40a1ed8fc97e1471636259f 100644 (file)
    '-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 <stddef.h> for offsetof.  */
-#include <stddef.h>
+   want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
 
 /* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
    standard headers, defines conflicting implementations of _Alignas
 #  else
    template <class __t> struct __alignof_helper { char __a; __t __b; };
 #   define _Alignof(type) offsetof (__alignof_helper<type>, __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)
 # define __alignas_is_defined 1
 #endif
 
+/* Include <stddef.h> if needed for offsetof.  */
+#if _GL_STDALIGN_NEEDS_STDDEF
+# include <stddef.h>
+#endif
+
 #endif /* _GL_STDALIGN_H */