[Base] Use pragma pack for non msvc as well.

- Pack attributes may be ignored by GCC
This commit is contained in:
Joel Linn 2021-05-18 16:06:01 +02:00 committed by Rick Gibbed
parent d55192ea30
commit d40dfa11c5
1 changed files with 8 additions and 9 deletions

View File

@ -85,18 +85,17 @@
#endif // XE_PLATFORM_MAC #endif // XE_PLATFORM_MAC
#if XE_COMPILER_MSVC #if XE_COMPILER_MSVC
#define XEPACKEDSTRUCT(name, value) \ #define _XEPACKEDSCOPE(body) __pragma(pack(push, 1)) body __pragma(pack(pop));
__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));
#else #else
#define XEPACKEDSTRUCT(name, value) struct __attribute__((packed)) name value; #define _XEPACKEDSCOPE(body) \
#define XEPACKEDSTRUCTANONYMOUS(value) struct __attribute__((packed)) value; _Pragma("pack(push, 1)") body; \
#define XEPACKEDUNION(name, value) union __attribute__((packed)) name value; _Pragma("pack(pop)");
#endif // XE_PLATFORM_WIN32 #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 { namespace xe {
#if XE_PLATFORM_WIN32 #if XE_PLATFORM_WIN32