Check if the compiler supports -Wpragma-pack (Clang supports this),
and enable -Wno-pragma-pack in that case. This silences warnings
like these:

    ../stdio/mingw_pformat.c:86:10: warning: the current #pragma pack alignment 
value is modified in the included file [-Wpragma-pack]

The fact that an included file changed the pragma pack alignment
is something that generally can be suspicious and Clang thinks this
is worth warning about, but the Windows headers <pshpack1.h>
specifically do this thing.

To avoid having to try to silence the warning inline, disable
this warning entirely in configure.ac.

GCC silently accepts options like -Wno-<diag> - but if such an
option is included and GCC prints a warning, it prints an extra
note saying that it didn't recognize the -Wno-<diag> option and
it may have been intended for silencing this warning.

Therefore, for checking support for a -Wno-<diag> option, check
for the positive form even if we are going to apply the negative
form of it.

Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-crt/configure.ac | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index b71b0564e..9d690c751 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -439,6 +439,17 @@ AS_CASE([$warning_level],
     ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration 
-Wmissing-noreturn -Wmissing-prototypes"]
    )
 
+saved_CFLAGS="$CFLAGS"
+AC_MSG_CHECKING([whether the compiler supports -Wpragma-pack])
+CFLAGS="$CFLAGS -Wpragma-pack"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
+    [supports_wpragma_pack=yes],[supports_wpragma_pack=no])
+AC_MSG_RESULT([$supports_wpragma_pack])
+if test "$supports_wpragma_pack" = "yes"; then
+    ADD_C_CXX_WARNING_FLAGS="$ADD_C_CXX_WARNING_FLAGS -Wno-pragma-pack"
+fi
+CFLAGS="$saved_CFLAGS"
+
 AC_SUBST(ADD_C_ONLY_WARNING_FLAGS)
 AC_SUBST(ADD_C_CXX_WARNING_FLAGS)
 AC_SUBST(ADD_CXX_ONLY_WARNING_FLAGS)
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to