On Wednesday 18 September 2024 12:05:44 Martin Storsjö wrote:
> On Sun, 15 Sep 2024, Pali Rohár wrote:
> 
> > When compiling any application with flags under gcc 7+ with flags
> > -D__MINGW_INTRIN_INLINE -Wall -Wextra, it throws about 300 lines of
> > preprocessor warnings for __INTRINSIC_PROLOG usage:
> > warning: this use of "defined" may not be portable
> 
> This isn't actually true for most installs of mingw-w64, so we probably
> should change this message somewhat.
> 
> ---
> If the mingw-w64 headers are included in a way that doesn't mute warnings in
> system headers, this header causes lots of warnings like:
> warning: this use of "defined" may not be portable
> ---
> 
> That makes the scope of the patch clear.

That is good, I'm fine with it.

> > It is caused by the fact that this macro __INTRINSIC_PROLOG uses
> > non-portable Conditional inclusion  (ISO WG14 N2176 (C17) 6.10.1/4).
> > 
> > Disable this gcc warning via localized GCC pragmas to prevent 300 lines of
> > warnings for every application.
> > ---
> > mingw-w64-headers/include/psdk_inc/intrin-impl.h | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> > 
> > diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h 
> > b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
> > index b30e0404ba88..06bbbfe4f7df 100644
> > --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
> > +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
> > @@ -67,6 +67,16 @@ __INTRINSICS_USEINLINE
> >   #define __has_builtin(x) 0
> > #endif
> > 
> > +/*
> > + * Macro __INTRINSIC_PROLOG uses non-portable Conditional inclusion
> > + * (ISO WG14 N2176 (C17) 6.10.1/4). Avoid gcc 7+ -Wexpansion-to-defined
> > + * warning enabled by -W or -Wextra option.
> > + */
> > +#if defined(__GNUC__) && __GNUC__ >= 7
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
> > +#endif
> 
> FWIW, Clang also has got this warning, but Clang presents itself as GCC 4.2
> in these defines, so we could do something like this:
> 
> #if defined(__GNUC__) && (__GNUC__ >= 7 || defined(__clang__))
> 
> If we don't care about exactly when Clang has learnt about this warning - I
> think it has been supported longer than we care about here. A quick dig in
> the code seems that it was renamed in Clang 3.9 in 
> https://github.com/llvm/llvm-project/commit/b5d539380a9b548f28ffa067067f90d3139ca767.
> So that's more than long enough.
> 
> Curiously, this warning isn't enabled in Clang with -Wall -Wextra, but it is
> enabled by -pedantic.
> 
> So I guess we could amend these #ifs to include this condition.
> 
> // Martin

Ok, feel free to adjust this check for clang.


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to