Recursive function pointer type. How?

Christopher R Volpe volpe at camelback.crd.ge.com
Wed Mar 13 23:37:05 AEST 1991


In article <17534 at crdgw1.crd.ge.com>, I wrote
|>In article <5144 at lure.latrobe.edu.au>, ECSGRT at lure.latrobe.edu.au
|>(GEOFFREY TOBIN, ELECTRONIC ENGINEERING) writes:
|>|>One way *around* the problem is to use "typedef void (* state) ();",
|>                                                  ^^^^
|>If the return value is void, there's nothing there to cast. I think
|>you meant: "typedef void *(*state)()".

Oops. One other thing I forgot. You wouldn't want to return a "void *"
if you're planning on casting that to a function pointer. Pointers to
void are not compatible with pointers to functions. You at least need
it to return a generic function pointer of some sort. Perhaps something
like: "typedef void (*(*state)())()". I.e., state is a pointer to a 
function that returns a vanilla function pointer. ("Vanilla function
pointer" means "pointer to function of unspecified arguments that
returns nothing", but this is irrelevant since it will be cast to the
proper function pointer type before invoking.)
                                                                     
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list