cochran_emc.h: packed structs

Dirk Hohndel dirk at hohndel.org
Tue Oct 28 08:09:20 PDT 2014


On October 28, 2014 8:05:20 AM "Lubomir I. Ivanov" <neolit123 at gmail.com> wrote:

> 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.

I can test clang. What about msvc?

/D





More information about the subsurface mailing list