Struct's alignment

Kapps opantm2+spam at gmail.com
Tue Aug 13 09:19:22 PDT 2013


On Saturday, 10 August 2013 at 20:36:24 UTC, Temtaime wrote:
> Hello, guys!
>
> I have Matrix class(that contains an array of 16 floats) and 
> SSE code to mult it.
> It's neccessary to have an array alignment 16.
>
> I'm figured out simple test-code:
>
> align(16) struct S {
> 	align(16) int a;
> }
>
>
> void main() {
> 	align(16) S s;
> 	writeln(cast(void *)&s.a);
> }
>
> And it prints 18FCC8, but must ends with "0". What i'm doing 
> wrong?
>
> Thanks.

Perhaps core.simd (http://dlang.org/phobos/core_simd.html) could 
be of help. I believe that those types should be aligned.


More information about the Digitalmars-d-learn mailing list