I'm using a function pointer based state machine. I need a function to check for different stats. The amount of functions is pretty massive. Therefore I would like to not use if else if else... chains. I would like to use a swithc case statement: I used the following code:
switch (my_state_func)
{
case &idle_state_func:
case NULL:
//...
break;
case &failed_func:
break;
default:
break;
}
Now the compiler tells me I can't use pointer in switch case
Is there a way to fix this? I tried integer casting of the pointer. This generates the error:
label doesn't reduce to an integer constant
case (int)&idle_func:
Is there maybe a macro or somthing? Logically it should be possible since every function point is a integer.
Thanks for help.