I came across what I thought was a unique syntax that I’ve never seen before (I mostly come from a C++ background). I’m not sure what the code is below. My guess is that it’s some sort of unique way of defining a struct, but if someone could clearly explain what they’re doing here, that would be a great help!
static Foo f =
{
.a = {DEFAULT_FOO},
.b = DEFAULT_BAR,
.c[0] = { 0 }
#ifdef BAR
,
.c[1] = { 0 },
.c[2] = { 0 }
#endif
};
This is C99 initialization syntax.
Note that a final comma is ok in C99, and the snippet could have been written
Note comma after
.c[0]and.c[2].