I have an enum like that:
enum {
ID_FOO = 0,
ID_BAR,
ID_BAZ
}
And a constant array using designated initializers like hat:
char* arr[] = {
[ID_FOO] = "foo stuff",
[ID_BAR] = "bar stuff",
[ID_BAZ] = "baz stuff",
0
}
Now when I add a value to the enum, e.g. after ID_FOO
but forget to add it to the array, then I would get an uninitialized null-initialized 'hole' in the array. Is there any way to prevent that, or at least get a warning from the compiler?
A non-portable GCC-only solution is fine.