When using aggregate / designated initialization of a struct it is possible to refer to another field like this:
#include <stdio.h>
int main()
{
struct
{
int a;
int b;
}
s =
{
.a = 3,
.b = s.a + 1,
};
return 0;
}
We use s.a in the initialization of s.b. However, we need to refer to s.a through s. Is it possible to refer directly to s.a as just .a, or similar? This would for instance make it possible to use the same syntax when initializing arrays of structs like here:
int main()
{
struct
{
int a;
int b;
}
s[] =
{
{
.a = 3,
.b = s[0].a + 1,
},
{
.a = 5,
.b = s[1].a - 1,
}
};
return 0;
}
Here we could maybe write something like .b = .a - 1 instead of .b = s[1].a - 1.