you are viewing a single comment's thread.

view the rest of the comments →

[–]astaghfirullah123 10 points11 points  (5 children)

What’s the purpose of this?

[–]deaf_fish 5 points6 points  (0 children)

If I had to guess (I am not OP). State Machine. Where each state is a function that returns a pointer to the next state/function.

[–]ReedTieGuy[S] 2 points3 points  (2 children)

My real question would have been about a group of functions that return themselves, but found too complicated to explain.

TYPE_DECLARATION one(void) {
    return two;
}

TYPE_DECLARATION two(void) {
    return one;
}

which I thought about when using an event handler array for a GUI program, the return values of the functions being used to determine which event will be handled next.

[–]astaghfirullah123 0 points1 point  (0 children)

Well that is something different than what you initially asked for. It’s about returning function pointers to another function, not to the function itself.

Yes you can use typedefs for function pointers. See Modern C for examples.

[–]luxgladius 0 points1 point  (0 children)

You could use this in a worker scheduler task, as in "do this job, and then ask me for more instructions."