Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!mit-eddie!uw-beaver!uw-june!pardo
From: pardo@june.cs.washington.edu (David Keppel)
Newsgroups: comp.lang.c
Subject: Re: Recursive function declarations
Message-ID: <5298@june.cs.washington.edu>
Date: 15 Jul 88 20:28:17 GMT
References: <323@sdrc.UUCP>
Reply-To: pardo@uw-june.UUCP (David Keppel)
Organization: U of Washington, Computer Science, Seattle
Lines: 32

In article <323@sdrc.UUCP> scjones@sdrc.UUCP (Larry Jones) writes:
>[ Function returning pointer to function returning pointer to fun...]
>[ How do I declare it? ]

To the best of my knowledge (correct me, please), you can't  You
need to declare it as returning a most-general pointer (void* if you
have one) and then cast it when you call:


    #include 

    /* a function returning a void* cast pointer to a function */
	void*
    foo()
    {
	static int i = 10;
	return  i-- ? (void*)foo : NULL;
    }

    main()
    {
	typedef void *(*fptr)();	/* ptr to func ret ptr to void */
	fptr func = foo;

	while ( func = (fptr)(*func)() ) {	/*VALUSED*/
	    printf( "looping\n" );
	}
	exit(0);
    }

(Gcc compiles and runs this on a VAX.  Whether it's correct, I dunno.)

	;-D on  ( Better chemistry through living )  Pardo