NULL ROUTINE POINTERS
kenny at uiucdcsb.CS.UIUC.EDU
kenny at uiucdcsb.CS.UIUC.EDU
Wed Dec 4 06:01:00 AEST 1985
/* Written 7:08 pm Nov 27, 1985 by jeff at isi-vaxa.arpa in uiucdcsb:net.lang.c */
/* ---------- "NULL ROUTINE POINTERS" ---------- */
After all the talk about null object pointers on machines with non-zero
null addresses, how would you portably define a null routine pointer?:
Assume that the routine returns a short, -
The following don't seem to work:
#define NULLROUTINE ((short *()) 0)
#define NULLROUTINE ((short *) 0())
And:
#define NULLROUTINE ((short *0)())
or
#define NULLROUTINE ((short)(*0)())
If all of the above make no sense...Then what?
Jeff /* End of text from
uiucdcsb:net.lang.c */
To make a cast, write a (fully-parenthesized) declaration of one item of the
desired type, and then take out the name. So, if you want a pointer to a
function returning short, you might say
short (*pfs) ();
To cast 0 to this type, it's
(short (*) ()) 0;
so
#define NULL_FUNCTION ((short (*) ()) 0)
Kevin
kenny at Uiuc.ARPA kenny at Uiuc.CSNET
{ihnp4, pur-ee, convex}!uiucdcs!kenny
No opinions are expressed here, so no disclaimer is needed.
More information about the Comp.lang.c
mailing list