[cfe-dev] 'struct' member alignment query
Martin J. O'Riordan via cfe-dev
cfe-dev at lists.llvm.org
Thu Feb 9 09:33:03 PST 2017
Wow! Thanks for the response, that worked perfectly.
I never would have expected that the indirect 'typedef' approach would behave any differently to the more direct annotation! I feel that this is probably an unintended GCC behaviour/bug, though CLang is 100% right to maintain compatibility with GCC.
But it solved my problem, thanks very much,
MartinO
-----Original Message-----
From: Tim Northover [mailto:t.p.northover at gmail.com]
Sent: 09 February 2017 15:08
To: Martin J. O'Riordan <Martin.ORiordan at movidius.com>
Cc: cfe-dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] 'struct' member alignment query
On 9 February 2017 at 02:56, Martin J. O'Riordan via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> Is this expected behaviour in 'clang', and if so, is there another way
> I can coerce the 'struct' member 'alignCheck2' onto another less
> constrained alignment boundary?
It's expected, but I think only because of GCC compatibility because it's really not obvious behaviour. The workaround, which still mystifies me, is to go via a typedef:
typedef AlignCheck_t __attribute__((aligned(1))) UnAlignCheck_t;
then you can put that in the struct and it'll be laid out without any padding.
Tim.
More information about the cfe-dev
mailing list