NULL etc.
Sean Levy
snl at cs.cmu.edu
Sun Jun 26 20:19:43 AEST 1988
Here's part of what I do:
#define NIL(t) ((t *)0) /* might change to some strange */
/* number for the 48-bit datapath
HP's :-) */
#define NULL NIL(char) /* for backwards compatibility */
Then, f'rinstance
struct hostent *hp;
hp = gethostbyname(argv[1]);
if (hp == NIL(struct hostent)) /* call lost */
...
I find this much easier to read. I don't write NULL in code anymore,
I use NIL(char). Being a combo Lisp/C programmer, NIL makes
more sense to me as a name for the pointer that points at nothing
than NULL does. I type fast enough that I don't really make an issue
of having to type an extra 5 characters to get what everyone seems to
call a "NULL pointer" on this list. I would add that distinctions between
0 and a pointer become VERY important at a place like CMU, where
code may be compiled on RT's, Suns, uVaxen and god knows what
else. The above #define's go in a header file called "basic.h" on my
personal include path. I only include <stdio.h> in modules that, well,
do I/O. I'm also going to switch completely to C++ verrrry soon...
Sean Levy
Engineering Desingn Research Center (EDRC), CMU
Internet: snl @ cs.cmu.edu
BITNET: snl%cs.cmu.edu at cmccvma
UUCP: beast me. here's a couple that seem to work
west coast: ...!{ucsdhub|sdcsvax}!snl at cs.cmu.edu
east cost: ...!harvard!snl at cs.cmu.edu
More information about the Comp.lang.c
mailing list