Doing a port of some C code that has an #ifdef in the middle of an initialization for an array of structs. I am getting a compile error trying to get equivalent behavior with "static if" or "version". Is there a way to achieve this other than making two separate array initialization sections?

struct a {
   int y;
   int z;
}

immutable string situation = "abc";

int main()
{
   a[] theArray = [
      { 10, 20 },
// version(abc)
static if (situation == "abc")
{
      { 30, 40 },
}
      { 50, 60 }
      ];
   return 0;
}

Reply via email to