EduardoFerrari
EduardoFerrari

Reputation: 11

Trouble with translation of typedef between C to D

I'm new on D programming and I am trying to translate a code from C to D, the actual line that I am having trouble is

typedef double Vec __attribute__ ((vector_size(16))); 

... I tried on:

alias Vez = double[16];

but it didnt work probably ... any help ?

Upvotes: 1

Views: 97

Answers (1)

BioTronic
BioTronic

Reputation: 2289

There's core.simd.Vector which does something similar. I'm not sure exactly what the differences are, but I'm sure there are some.

The one I know about is Vector takes the number of elements instead of the size in bytes, so

typedef double Vec __attribute__ ((vector_size(16))); 

becomes

import core.simd : Vector;
alias Vec = Vector!(double[2]);

However, DMD only supports this for x64. It works in LDC for both 32-bit and 64-bit architectures, and I believe the same is true for GDC.

Upvotes: 3

Related Questions