* [PATCH] undef offsetof before defining it in stddef.h
@ 2022-09-30 16:35 Olivier Hainque
2022-10-06 12:17 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Olivier Hainque @ 2022-09-30 16:35 UTC (permalink / raw)
To: gcc-patches; +Cc: Olivier Hainque
[-- Attachment #1: Type: text/plain, Size: 780 bytes --]
Hello,
The attached patch is a proposal to #undef offsetof before
the #define we do in ginclude/stddef.h, which prevents redefinition
warnings from dg tests passing -Wsystem-headers on systems which
provide a definition in system headers, such as VxWorks.
We have been using this for a while with gcc-11 based toolchains
for a wide range of configurations (linux and windows hosts, native
and cross, bare board or VxWorks for a range of CPUs).
This also passes build + sanity test with gcc-12 for
powerpc64-vxworks7r2, then full bootstrap + regression testing
for mainline on x86_64-linux.
Ok to commit?
Thanks in advance!
With Kind Regards,
Olivier
2022-09-30 Olivier Hainque <hainque@adacore.com>
gcc/
* ginclude/stddef.h: #undef offsetof before #define.
[-- Attachment #2: 0003-undef-offsetof-before-defining-it-in-stddef.h.patch --]
[-- Type: application/octet-stream, Size: 1072 bytes --]
From 365b8343d8f882926d817b81243990ff66945d7c Mon Sep 17 00:00:00 2001
From: Olivier Hainque <hainque@adacore.com>
Date: Fri, 28 Jan 2022 16:34:50 +0000
Subject: [PATCH 03/18] undef offsetof before defining it in stddef.h
This prevents redefinition warnings by -Wsystem-headers on
OSses where system headers happen to provide a definition of
their own, such as VxWorks.
2022-02-15 Olivier Hainque <hainque@adacore.com>
gcc/
* ginclude/stddef.h: #undef offsetof before #define.
---
gcc/ginclude/stddef.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
index 3d29213e8f1..2767edf51de 100644
--- a/gcc/ginclude/stddef.h
+++ b/gcc/ginclude/stddef.h
@@ -412,6 +412,7 @@ typedef __WINT_TYPE__ wint_t;
#ifdef _STDDEF_H
/* Offset of member MEMBER in a struct of type TYPE. */
+#undef offsetof /* in case a system header has defined it. */
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \
--
2.25.1
[-- Attachment #3: Type: text/plain, Size: 3 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] undef offsetof before defining it in stddef.h
2022-09-30 16:35 [PATCH] undef offsetof before defining it in stddef.h Olivier Hainque
@ 2022-10-06 12:17 ` Richard Biener
2022-10-06 16:49 ` Olivier Hainque
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-10-06 12:17 UTC (permalink / raw)
To: Olivier Hainque; +Cc: gcc-patches
On Fri, Sep 30, 2022 at 6:35 PM Olivier Hainque via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hello,
>
> The attached patch is a proposal to #undef offsetof before
> the #define we do in ginclude/stddef.h, which prevents redefinition
> warnings from dg tests passing -Wsystem-headers on systems which
> provide a definition in system headers, such as VxWorks.
>
> We have been using this for a while with gcc-11 based toolchains
> for a wide range of configurations (linux and windows hosts, native
> and cross, bare board or VxWorks for a range of CPUs).
>
> This also passes build + sanity test with gcc-12 for
> powerpc64-vxworks7r2, then full bootstrap + regression testing
> for mainline on x86_64-linux.
>
> Ok to commit?
OK.
> Thanks in advance!
>
> With Kind Regards,
>
> Olivier
>
> 2022-09-30 Olivier Hainque <hainque@adacore.com>
>
> gcc/
> * ginclude/stddef.h: #undef offsetof before #define.
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-06 16:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 16:35 [PATCH] undef offsetof before defining it in stddef.h Olivier Hainque
2022-10-06 12:17 ` Richard Biener
2022-10-06 16:49 ` Olivier Hainque
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).