I had no idea you could do that in C.
It sure would be a great feature in C++.
In more complicated cases, it can be much more important to initialize members (or map contents, etc.) by name.
I usually do this (quoted from memory, not retested, so I might have some detail wrong):
Code:
int main()
{
struct f_initialized : public Foo {
f_initialized() {
Foo &x = *this;
x.value1 = 10;
x.value3 = 20; }
} f;
}
Obviously, that is a lot of overhead just for initializing a couple members. But in many cases (such as class static variables) you really want the initialization done as part of construction of the object. Sometimes the limited syntax of the existing constructor or initialization list is too restrictive.
If the above code isn't obvious: It defines a class derived from Foo for the purposes of initializing this one object. Inside the class definition, it defines a constructor which does the desired initialization by member name. Then it defines f as a single instance of that class.
In some cases, there may be consequences from the fact that the type of f is f_initialized rather than Foo. But in most cases where I have used this idiom, that detail doesn't matter.