Static Initialization of Struct as UDA

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 13 15:04:48 PDT 2017


The code below doesn't compile because "static variable z cannot 
be read at compile time". However, z is a static variable, so I 
don't see why it wouldn't be available at compile-time.

Bug or am I missing something?

struct Bar
{
     int x = 2;
     int y;
}

static Bar z = {y:1};

void main()
{
     @z int d;
     //@Bar(2, 1) int d; //this compiles, but requires putting x 
in there
}


More information about the Digitalmars-d-learn mailing list