Consider:
struct N {
struct N *next, *prev;
};
struct X {
struct N *first, *last;
};
int fun()
{
struct X tmp = {
.first = &(struct N) {.next = ???},
.last = &(struct N) {.prev = ???},
};
return 0;
}
void main()
{
fun();
}
I come across situations, like the above, where it would be really useful to be able to get a pointer to the structure I'm initializing as part of the initialization process. Something like "this" in C++. I realize I can use the name of the variable, but that precludes doing something like:
struct X x = MAGIC_INITIALIZER_MACRO;
Is there a way to do this?
And as long as I'm on the subject of initialization, if the order of the initialization statements doesn't match the order they are declared in the structure, which order does the compiler use?