Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes: > However, if we had to change the lookup such that it uses an array always, > we would have to introduce a function to initialize the struct, always, in > particular we would have to find a place to call that initialization > function in, say, builtin/fsck.c (actually, in every code path that calls > into the fsck machinery). You would need to call a function to "initialize" the table if you support customization by reading the configuration files anyway. I am not sure why you think finding such a place is hard. Puzzled. Also I suspect that you can tell the compiler to initialize the array in place with default values, perhaps like this? -- >8 -- #include <stdio.h> /* sorted by the default severity (lowest impact first) */ #define EVENT_LIST(F) \ F(EVENT_A), \ F(EVENT_B), \ F(EVENT_C), \ F(EVENT_D) #define ID_(event) ID_ ## event enum event_id { EVENT_LIST(ID_) }; enum severity_level { severity_info, severity_warn, severity_error }; /* below this one are INFO */ #define FIRST_WARN_EVENT_ID ID_EVENT_B /* below this one are WARN */ #define FIRST_ERROR_EVENT_ID ID_EVENT_C #define STRING_(s) #s #define DESC_(event) \ { \ ID_ ## event, \ STRING_(event), \ (ID_ ## event < FIRST_WARN_EVENT_ID \ ? severity_info \ : ID_ ## event < FIRST_ERROR_EVENT_ID \ ? severity_warn \ : severity_error) \ } struct event_config { enum event_id id; const char * name; enum severity_level level; } event[] = { EVENT_LIST(DESC_) }; int main(int ac, char **av) { int i; for (i = 0; i < sizeof(event) / sizeof(event[0]); i++) { printf("%d, %s, %d\n", event[i].id, event[i].name, event[i].level); } return 0; } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html