Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Abandon NULL for (0) Message-ID: <19999@mimsy.UUCP> Date: 6 Oct 89 11:43:39 GMT References: <252B5E41.1244@marob.masa.com> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <252B5E41.1244@marob.masa.com> daveh@marob.masa.com (Dave Hammond) writes: [`#define NIL(t) (t *)0' works for most types] >The only pathological case which I define a separate macro for is >null pointer-to-function: > >#define NILFUNC(t) (t (*)())0 Note that in Classic C, this is a `pointer to function returning t', but in New C, this is a `pointer to function of unknown arguments returning t' and that the latter type is Officially Frowned Upon. One is supposed to write monstrosities like void (*signal(int, void (*)(int)))(int); Then a nil pointer (which, incidentally, is not as an action defined for signal(), although SIG_DFL is usually a nil pointer) of the appropriate type can be made with #define SIG_DFL ((void (*)(int)) 0) It all gets a bit clearer with typedefs: typedef void (*pointer_to_signal_function)(int); pointer_to_signal_function signal(int, pointer_to_signal_function); #define SIG_DFL ((pointer_to_signal_function) 0) (except, of course, that implementors are not allowed to use the name `pointer_to_signal_function'---you are more likely to see something like the original, or like typedef void (*__sfp_t)(int); __sfp_t signal(int, __sfp_t); #define SIG_DFL ((__sfp_t) 0) in your ). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris