A function will have no more than 64 code blocks, each of which can use an anonymous function or a named one:
my_func_array[64] = { [CONDITION(1,0,0,0,0,0)] = { codeblock1 }, [CONDITION(0,1,0,0,0,0)] = { codeblock2 }, ... };
The macro basically combines the 6 first entries in the index, essentially translating into:
my_func_array[64] = { [32] = { ... }, [16] = { ... }, };
means you do not need to enter conditions in any particular order ...
At startup, you should also evaluate all the conditions:
int condition = CONDITION(a < MAX1, b < MAX2, c < MAX2, ...); if (my_func_array[condition]) my_func_array[condition](); else {
Aki suihkonen
source share