Is #define NULL 0L ok?

Guy Harris guy at rlgvax.UUCP
Tue Mar 13 11:31:07 AEST 1984


> 	#include <stdio.h>
> 	#undef	NULL
> 	#define	NULL 0L

> This works fine on the VAX, but then so did NULL=0.  Can any
> reader with a ptr=32&int=16 C compiler tell me if this is ok
> for such compilers?

Yes, it works on our compiler.  However, "lint" will *still* yell at
you (it isn't complaining about the size of the object, it's complaining
about its type), it means the code won't work on a 16-bit machine (even
if it would fit) nor will it work on a machine where (to pick a possibly
strange example) pointers and "int"s are 32 bits while "long"s are 64 bits,
and it won't work on a machine where the representation of a null pointer
isn't a string of all zero bits.  Why not just run the code through "lint"
and read and heed its warnings?

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list