[PATCH] features.h: Fix -Wundef problems
Corinna Vinschen
vinschen@redhat.com
Thu Dec 4 10:10:12 GMT 2025
On Dec 3 03:48, Stefan Tauner wrote:
> [...]
> From 4667f7d3f13cfc051db048efbf1636ecc25d2532 Mon Sep 17 00:00:00 2001
> From: Stefan Tauner <stefan.tauner@gmx.at>
> Date: Sat, 29 Nov 2025 22:52:26 +0100
> Subject: [PATCH] features.h: Fix -Wundef problems
>
> -Wundef warns if an undefined identifier is evaluated in an #if
> directive. This would be valid as they are replaced with 0. However, it
> is often an early warning sign and not intentional. To allow for
> enabling -Wundef even outside system directories (where compilers
> ignore such problems unless -Wsystem-headers is enabled) this patch
> adds the required defined() checks.
>
> glibc also has been supporting this for 10 years now:
> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f248238cf43bd751db29e6f151d6da7645337ff5
>
> I have not exhaustively tested this but you can see the effect with
> something like the following (+ using -stdc= and/or -D...):
> echo | gcc -include newlib/libc/include/sys/features.h -Inewlib/libc/include/ -E - -Wundef
>
> Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
> ---
> newlib/libc/include/sys/features.h | 49 +++++++++++++++++-------------
> 1 file changed, 28 insertions(+), 21 deletions(-)
Pushed.
Thanks,
Corinna
More information about the Newlib
mailing list