Recursive declaration of function pointer in C
问题 I\'d like to declare a function that returns a pointer to a function of the same type. I would like to use it to implement state machines like the one below: typedef event_handler_t (*event_handler_t)(event_t*); // compilation error event_handler_t state2(event_t* e); event_handler_t state1(event_t* e) { switch(e->type) { //... case SOME_EVENT: return state2; //... } } event_handler_t state2(event_t* e) { switch(e->type) { //... case OTHER_EVENT: return state1; //... } } //... event_handler_t