I went down a rabbithole and wow.
Found a comment from the author of https://github.com/stclib/STC apparently and then came across this example:
https://stackoverflow.com/a/76887723
int coro_a(struct a* g)
{
cco_routine (g) {
printf("entering a\n");
for (g->i = 0; g->i < 3; g->i++) {
printf("A step %d\n", g->i);
cco_yield();
}
cco_final:
printf("returning from a\n");
}
return 0; // done
}
gcc -E -ISTC/include co.cAfter running it through a preprocessor, it gives me this.
int coro_a(struct a* g)
{
for (int* _state = &(g)->cco_state; *_state != CCO_STATE_DONE; *_state = CCO_STATE_DONE) _resume: switch (*_state) case 0: {
printf("entering a\n");
for (g->i = 0; g->i < 3; g->i++) {
printf("A step %d\n", g->i);
do { *_state = 14; return CCO_YIELD; goto _resume; case 14:; } while (0);
}
*_state = CCO_STATE_FINAL; case CCO_STATE_FINAL:
printf("returning from a\n");
}
return 0;
}