headers: Disable gcc warning that __INTRINSIC_PROLOG is not portable

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

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.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Pali Rohár 2024-09-15 17:32:28 +02:00 committed by Martin Storsjö
parent b9cacd918c
commit 0be496546a

View File

@ -67,6 +67,17 @@ __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.
* In Clang, this warning is enabled by -pedantic.
*/
#if defined(__GNUC__) && (__GNUC__ >= 7 || defined(__clang__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
#endif
/* These macros are used by the routines below. While this file may be included
multiple times, these macros only need to be defined once. */
#ifndef _INTRIN_MAC_
@ -2289,6 +2300,10 @@ __build_writecr(__writecr8, unsigned __LONG32, "8")
#undef __FLAGCLOBBER1
#undef __FLAGCLOBBER2
#if defined(__GNUC__) && (__GNUC__ >= 7 || defined(__clang__))
#pragma GCC diagnostic pop
#endif
#pragma pop_macro("__has_builtin")
#endif /* __MINGW_INTRIN_INLINE */