Earlier quoted context omitted.
Would be happy with a enum that's a named key value. key_enum one_two_three { FIRST = { .name = "first"}, SECOND = { .name = "second"}, THIRD = { .name = "third"}, LAST = { .value = 255, .name = "last"}, };
What is wrong with the following? Do you want type more type safety, e.g. linking the enumeration constants to the array? enum { FIRST, SECOND, THIRD }; struct { char *name; int value; } table[] = { [FIRST] = { .name = "FIRST", .value = 0 }, [SECOND] = { .name = "SECOND", .value = 1 }, [THIRD] = { .name = "THIRD", .value = 3 }, };
Nothing really difficult, normally all of this is done by hand, which is tedious and error prone, or incorporated in a macro. It would just be nice if there was a standard provided turn-key solution to the problem.