Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rutgers!cmcl2!phri!marob!daveh From: daveh@marob.masa.com (Dave Hammond) Newsgroups: comp.lang.c Subject: Re: Abandon NULL for (0) Message-ID: <252B5E41.1244@marob.masa.com> Date: 5 Oct 89 13:59:27 GMT Reply-To: daveh@marob.masa.com (Dave Hammond) Organization: ESCC, New York City Lines: 26 In article <10839@dasys1.UUCP> jpr@dasys1.UUCP (Jean-Pierre Radley) writes: >I have found my code to more readable if I use these two defines: > >#define NULLC (char *)0 >#define NULLF (FILE *)0 > For the vast majority of data types, a single macro can produce a properly cast null pointer: #define NIL(t) (t *)0 This produces fairly readable and maintainable code, as in: fp = fopen("foo","r"); if (fp == NIL(FILE)) { ... } The only pathological case which I define a separate macro for is null pointer-to-function: #define NILFUNC(t) (t (*)())0 -- Dave Hammond daveh@marob.masa.com