The "switch" method isn't too uncommon, but usually people have an init function and "state" pointer that's passed into the coroutine function. I've used this method a lot in embedded projects, where one coroutine was handling motor acceleration/deceleration while the other would simply tell it what direction to go, but I've also used it for networked libraries[1]. Even the standard library has a coroutine function like this in "strtok()"[2]
You don't really need to introduce macro hell for it to be manageable, though I've never found reading switch/case flow to be very enjoyable.
You don't really need to introduce macro hell for it to be manageable, though I've never found reading switch/case flow to be very enjoyable.
[1]: https://github.com/REONTeam/libmobile/blob/master/relay.c#L3...
[2]: https://manpages.debian.org/bookworm/manpages-dev/strtok.3.e...