State machines in C

前端 未结 9 1724
一整个雨季
一整个雨季 2021-01-30 07:34

What is the best way to write a state machine in C?
I usually write a big switch-case statement in a for(;;), with callbacks to re-enter the state machine when an external

9条回答
  •  醉话见心
    2021-01-30 08:24

    Switch statements are a good way to get started, but they tend to get unwieldy when the FSM gets larger.

    A couple related (or duplicate) SO questions with great information and ideas:

    • state machines tutorials
    • C state-machine design

提交回复
热议问题