I am trying to create a threaded state machine where each state returns a pointer to the next state. I have a number of state machines running so the next state of all these is stored in an array that is sequenced through to call them in a round robin fashion. So what I would like to do is:
pState[i] = (pState[i])();
I understand how to return a function pointer in general but since I need the returned pointer to be a type of function that returns a pointer to a function the recursion is confusing me. The state would look like:
pSatateFunc StateA(void){
// ... code ...
return StateB;
}
So, how do I define this so I can define the array of pointers?