NULL ROUTINE POINTERS

Morris M. Keesan keesan at bbncc5.UUCP
Tue Dec 3 07:12:38 AEST 1985


The request was for a way to specify a null pointer to a function returning
short.  Doug Gwyn correctly responded with ((short (*)()) 0).  Note that the
form of the type specification is copied directly from section 8.7 of the
C Reference Manual in K&R (page 200), and therefore very safe.
For real readability, I as usual suggest the typedef method:

typedef short FS();     /* FS = Function returning Short */
typedef FS *PFS;        /* PFS = Pointer to Function returning Short */
#define NULLROUTINE ((PFS)0)    /* Isn't this much clearer? */
-- 
Morris M. Keesan
keesan at bbn-unix.ARPA
{decvax,ihnp4,etc.}!bbncca!keesan



More information about the Comp.lang.c mailing list