routines which return function pointers

Mark Terribile mat at hou4b.UUCP
Thu Dec 27 00:49:21 AEST 1984

	A friend, who can't post, has asked me to put this up.  Please
send mail to him, not to me!

	Merry X-snacks!	(a former dessert)

There has been a lot of discussion about casting a pointer to char
as a pointer to a function, but Whitesmith's has gone one better.
Here is a page from section 2 describing 'onexit' which is passed
a pointer to a function returning a function to a pointer!!!!!
(copied without anybodys permission, so don't tell)

	onexit - call function on program exit

	VOID	(*onexit())(pfn)
	VOID	(*(*pfn)())();

	onexit registers the function pointed at by pfn, to be
	called on program exit.  The function at pfn is obligated
	to return the pointer returned by the onexit call, so that any
	previously registered functions can also be called.

	onexit returns a pointer to another function; it is guaranteed
	to be non-null

	GLOBAL VOID (*(*nextguy)())(), (*thisguy())();

	if( !nextguy )
		nextguy = onexit (&thisguy);


	the type declaractions defy description, and are still wrong

		|  Jeff 'oh my gawd - another one' Skot  |
		| who's spending too much time at ATT IS |
		|  in beautiful downtown Somerset N.J.   |
		|     but known to you as abnji!jeff     |


	from Mole End			Mark Terribile
		(scrape .. dig )	hou4b!mat
    ,..      .,,       ,,,   ..,***_*.

More information about the Comp.lang.c mailing list