Hi, here're 3 patches that fixes the usage of #pragma pack.
From 4784ed8b3c5216a2d2f282c20f7eee1bcd2ce522 Mon Sep 17 00:00:00 2001
From: Zhongteng Gui <[email protected]>
Date: Thu, 3 Sep 2026 23:41:24 +0800
Subject: [PATCH 1/3] headers: stdlib.h: fix #pragma pack
`#pragma pop()` restores to "default packing" instead of "previous
packing", which can potentially cause problems and/or generate warnings.
Signed-off-by: Zhongteng Gui <[email protected]>
---
mingw-w64-headers/crt/stdlib.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index 396282210..c4c2ff013 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -39,11 +39,11 @@ _CRT_BEGIN_C_HEADER
#ifndef _CRT_DOUBLE_DEC
#define _CRT_DOUBLE_DEC
-#pragma pack(4)
+#pragma pack(push, 4)
typedef struct {
unsigned char ld[10];
} _LDOUBLE;
-#pragma pack()
+#pragma pack(pop)
#define _PTR_LD(x) ((unsigned char *)(&(x)->ld))
@@ -64,11 +64,11 @@ _CRT_BEGIN_C_HEADER
#pragma pop_macro("long")
-#pragma pack(4)
+#pragma pack(push, 4)
typedef struct {
unsigned char ld12[12];
} _LDBL12;
-#pragma pack()
+#pragma pack(pop)
#endif
#define RAND_MAX 0x7fff
--
2.55.0.windows.5
From dec1d1de2ddaf915519e310c9a61d99b6a80d1b0 Mon Sep 17 00:00:00 2001
From: Zhongteng Gui <[email protected]>
Date: Thu, 3 Sep 2026 23:53:12 +0800
Subject: [PATCH 2/3] crt: Don't use pshpackX.h and poppack.h
Clang will generate -Wpargma-pack for this.
Signed-off-by: Zhongteng Gui <[email protected]>
---
mingw-w64-crt/math/DFP/dfp_internal.h | 4 ++--
mingw-w64-crt/stdio/mingw_pformat.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/mingw-w64-crt/math/DFP/dfp_internal.h
b/mingw-w64-crt/math/DFP/dfp_internal.h
index 32d81ce86..440803739 100644
--- a/mingw-w64-crt/math/DFP/dfp_internal.h
+++ b/mingw-w64-crt/math/DFP/dfp_internal.h
@@ -117,7 +117,7 @@ DFP = -1^s x tttt x [ 10 ^ (eeee - (6176(base10))]
*/
-#include <pshpack1.h>
+#pragma pack(push, 1)
#ifdef __GNUC__
#define structpack __attribute__((gcc_struct))
#else
@@ -202,7 +202,7 @@ typedef type0d64 _Decimal64;
typedef type0d128 _Decimal128;
#endif /* _MSC_VER */
-#include <poppack.h>
+#pragma pack(pop)
typedef union ud32 {
_Decimal32 d;
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c
b/mingw-w64-crt/stdio/mingw_pformat.c
index 84e62f5d4..2bbe5203b 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -84,7 +84,7 @@
* is better to just keep these definitions here.
*/
-#include <pshpack1.h>
+#pragma pack(push, 1)
/* workaround gcc bug */
#if defined(__GNUC__) && !defined(__clang__)
#define ATTRIB_GCC_STRUCT __attribute__((gcc_struct))
@@ -103,7 +103,7 @@ typedef union ATTRIB_GCC_STRUCT __uI128 {
__tI128 t128;
__tI128_2 t128_2;
} __uI128;
-#include <poppack.h>
+#pragma pack(pop)
#ifndef _VALUES_H
/*
--
2.55.0.windows.5
From 41ae87d7be9ea211a45b70aa6017c928b1397dd7 Mon Sep 17 00:00:00 2001
From: Zhongteng Gui <[email protected]>
Date: Thu, 3 Sep 2026 23:39:22 +0800
Subject: [PATCH 3/3] crt: Don't check / disable -Wpragma-pack.
This is no longer needed after previous 2 commits.
Signed-off-by: Zhongteng Gui <[email protected]>
---
mingw-w64-crt/configure.ac | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index c71d1b7e7..dd73c3306 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -439,15 +439,6 @@ AS_CASE([$warning_level],
)
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_MSG_CHECKING([whether the compiler supports -Warray-bounds])
CFLAGS="$CFLAGS -Warray-bounds"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
--
2.55.0.windows.5
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public