hello; i want to know that where we use link list, function pointer, generic pointer in embedded programming
If each case just calls a function, those functions might happen to have switch statement inside, but won't cause readability and indentation problems.
Exactly, thanks for guessing my thoughts.
#define STATE_INIT 0 #define STATE_WORK 1 void state_machine() { static int current_state = STATE_INIT; switch(current_state) { case STATE_INIT: current_state = state_init(); break; case STATE_WORK: current_state = state_work(); break; default: current_state = STATE_INIT; break; } } int state_init() { return(STATE_WORK); } int state_work() { return(STATE_WORK); }
Something along those lines.