cochran_emc.h: packed structs

Lubomir I. Ivanov neolit123 at gmail.com
Tue Oct 28 08:04:30 PDT 2014


On 28 October 2014 16:28, Dirk Hohndel <dirk at hohndel.org> wrote:
> On Tue, Oct 28, 2014 at 01:28:47PM +0200, Lubomir I. Ivanov wrote:
>> } __attribute__((packed));
>> is unreliable with MINGW > 4.6 up until 4.8.2 - the one i have bundled
>> with the Qt 5.3.
>
> Yes, Jef pointed that out (with less detail) on the libdivecomputer
> mailing list.
>
>> padding is added regardless and there is high potential for the code to break.
>>
>> one solution would be to branch / use "#pragma pack()" which is an
>> MSVC thing but recent MINGW supports it.
>>
>> i'm CCing John Van Ostrand as the author, and posting this message so
>> that everyone knows.
>> perhaps there is a need for a SUBSURFACE_PACK_STRUCT(x) macro of sorts.
>
> Is there a reliable way to do packed structures with mingw, msvc and gcc?
> If yes then I would love to have such a macro (or however this would be
> done).  Being able to do this would make code so much more readable.
>
> We might even convince Jef to allow use of such a construct (after it's
> sufficiently tested) in libdivecomputer which would do wonders for my
> sanity :-)
>

here is a solution (found online) that uses 'gcc_struct'.
the attribute itself exists since 3.4.x.
by coupling with 'packed' it respects the forced packing - tested on
mingw 4.8.2!
'packed' not working in general still remains a bug...

something to note - in the manual, they do not mention if it exists
for GCC-ARM, but i would assume it does.
also i have no idea if clang has it.

lubomir
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Use-gcc_struct-with-the-packed-attribute.patch
Type: application/octet-stream
Size: 2170 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20141028/9ee8f8dd/attachment.obj>


More information about the subsurface mailing list