From 859d5585090d966a222da6bc4f14f0d749d13277 Mon Sep 17 00:00:00 2001 From: Ries van Twisk Date: Mon, 30 Dec 2019 12:12:22 +0100 Subject: FreePIE Use packed struct with clang to receive datagram --- tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp index 6622a3b7..8c4d7c47 100644 --- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -17,13 +17,21 @@ tracker_freepie::~tracker_freepie() } void tracker_freepie::run() { -#pragma pack(push, 1) - struct { +#ifdef __clang__ + struct __attribute__((packed)) { uint8_t pad1; uint8_t flags; float fl[12]; - } data {}; -#pragma pack(pop) + } data {}; +#else + #pragma pack(push, 1) + struct { + uint8_t pad1; + uint8_t flags; + float fl[12]; + } data {}; + #pragma pack(pop) +#endif enum F { -- cgit v1.2.3 From 678ba1e120b033ee877f70c24913ff049a7f731f Mon Sep 17 00:00:00 2001 From: Ries van Twisk Date: Mon, 30 Dec 2019 23:26:47 +0100 Subject: Ensure structure is the same --- tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp index 8c4d7c47..28d29351 100644 --- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -17,22 +17,22 @@ tracker_freepie::~tracker_freepie() } void tracker_freepie::run() { -#ifdef __clang__ - struct __attribute__((packed)) { +#ifndef __clang__ +#pragma pack(push) +struct +#else +struct __attribute__((packed)) +#endif +{ uint8_t pad1; uint8_t flags; float fl[12]; - } data {}; -#else - #pragma pack(push, 1) - struct { - uint8_t pad1; - uint8_t flags; - float fl[12]; - } data {}; - #pragma pack(pop) +} data; +#ifndef __clang__ +#pragma pack(pop) #endif + enum F { flag_Raw = 1 << 0, -- cgit v1.2.3