Unresolvable self-reference
This is not possible directly. If you try to define a function pointer type where the function's return type is its own type, you will run into an unresolved self-reference, and that would require infinite recursion to resolve.
typedef funcType (*funcType)(void);
Return a struct
You can instead declare that the function return a structure, and the structure can contain a pointer to such a function.
struct func {
struct func (*func) (void);
};
struct func foo (void);
struct func bar (void);
struct func foo (void) { return (struct func){ bar }; }
struct func bar (void) { return (struct func){ foo }; }
...
struct func funcPtr = { foo };
funcPtr = funcPtr.func();
Return a different function pointer type
If you prefer to stick to strictly pointers, you will need to resort to defining functions that return a different function pointer type. Thus, the result of the call would have to be cast back to the proper pointer type before being invoked.
typedef void (*funcPtrType)(void);
typedef funcPtrType funcType(void);
funcType foo;
funcType bar;
funcPtrType foo (void) { return (funcPtrType)bar; }
funcPtrType bar (void) { return (funcPtrType)foo; }
...
funcType *p = foo;
p = (funcType *)p();
Return an index†
You could instead define your functions to return an index to a table that represents the function that should be invoked.
enum funcEnum { fooEnum, barEnum };
typedef enum funcEnum (*funcType)(void);
enum funcEnum foo (void) { return barEnum; }
enum funcEnum bar (void) { return fooEnum; }
funcType funcTable[] = { [fooEnum] = foo, [barEnum] = bar };
...
funcType p = funcTable[fooEnum];
p = funcTable[p()];
†This was raised in comments and in Paul's answer, but presented here for completeness.
typedef void func_t (int, int);andfunc_t* func1 (int a, int b);