From d40dfa11c54388172b8852cc8a49f103dc20abe7 Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Tue, 18 May 2021 16:06:01 +0200 Subject: [PATCH] [Base] Use pragma pack for non msvc as well. - Pack attributes may be ignored by GCC --- src/xenia/base/platform.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/xenia/base/platform.h b/src/xenia/base/platform.h index 441d37750..04e678bd4 100644 --- a/src/xenia/base/platform.h +++ b/src/xenia/base/platform.h @@ -85,18 +85,17 @@ #endif // XE_PLATFORM_MAC #if XE_COMPILER_MSVC -#define XEPACKEDSTRUCT(name, value) \ - __pragma(pack(push, 1)) struct name value __pragma(pack(pop)); -#define XEPACKEDSTRUCTANONYMOUS(value) \ - __pragma(pack(push, 1)) struct value __pragma(pack(pop)); -#define XEPACKEDUNION(name, value) \ - __pragma(pack(push, 1)) union name value __pragma(pack(pop)); +#define _XEPACKEDSCOPE(body) __pragma(pack(push, 1)) body __pragma(pack(pop)); #else -#define XEPACKEDSTRUCT(name, value) struct __attribute__((packed)) name value; -#define XEPACKEDSTRUCTANONYMOUS(value) struct __attribute__((packed)) value; -#define XEPACKEDUNION(name, value) union __attribute__((packed)) name value; +#define _XEPACKEDSCOPE(body) \ + _Pragma("pack(push, 1)") body; \ + _Pragma("pack(pop)"); #endif // XE_PLATFORM_WIN32 +#define XEPACKEDSTRUCT(name, value) _XEPACKEDSCOPE(struct name value) +#define XEPACKEDSTRUCTANONYMOUS(value) _XEPACKEDSCOPE(struct value) +#define XEPACKEDUNION(name, value) _XEPACKEDSCOPE(union name value) + namespace xe { #if XE_PLATFORM_WIN32