From 86532fa21dee16debf4f96a8b6eb6e894076845e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Wed, 31 May 2023 17:48:36 +0200 Subject: [PATCH] util: Use the gcc_struct attribute for packed structures in mingw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actually set the packing behavior as the intended one when using this attribute, even on mingw. Otherwise, the default behavior is to use the ms_struct which makes the structures use more space in some situations. Signed-off-by: Corentin Noël Part-of: --- src/util/macros.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index d79848ad997..c474d7571d7 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -204,7 +204,11 @@ do { \ * packed, to trade off performance for space. */ #ifdef HAVE_FUNC_ATTRIBUTE_PACKED -#define PACKED __attribute__((__packed__)) +# if defined(__MINGW32__) || defined(__MINGW64__) +# define PACKED __attribute__((gcc_struct,__packed__)) +# else +# define PACKED __attribute__((__packed__)) +# endif #else #define PACKED #endif