Generating struct .init at run time?
kinke
noone at nowhere.com
Thu Jul 2 16:51:52 UTC 2020
On Thursday, 2 July 2020 at 15:20:23 UTC, Ali Çehreli wrote:
> According to its date, it was written when I was working for
> Weka. Apparently, ldc took care of it for them after all.
If so, then without them posting any issue beforehand or giving
any feedback afterwards.
> > For recent LDC versions, the 'solution' is to (statically)
> initialize
> > the array with zeros, as fully zero-initialized structs don't
> feature
> > any explicit .init symbols anymore.
>
> What about floating point and char types? Their .init values
> are not all zeros in D spec. (I don't think this matters in my
> case but still.)
That's why all you have to do, in order not to have recent LDC
emit the struct's init symbol, is to initialize these members
manually with zeros:
struct S { double[elementCount] a = 0; }
void foo() { S s; } // compiler does a memset
`= void` for members doesn't work and, I dare say, not work
anytime soon if ever.
More information about the Digitalmars-d-learn
mailing list