How to represent struct with trailing array member

Dibyendu Majumdar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 21 13:52:06 PST 2016


Hi

I have C code where the struct has a trailing array member:

struct matrix {
   int rows;
   int cols;
   double data[1];
};

In C code this is allocated dynamically to be variable size. The 
array is used just as normal.

How should this be translated to D? Will D's array access allow 
data elements to be accessed beyond the size declared?

Thanks and Regards
Dibyendu


More information about the Digitalmars-d-learn mailing list