[comp.lang.c] Portable NULL pointers

andrew@motto.UUCP (Andrew Walduck) (09/28/90)

goudreau@dg-rtp.dg.com (Bob Goudreau) writes:
>> The Second Original Sin was the failure to make "NULL" a keyword.
roy@phri.UUCP (Roy Smith) writes:
>What about this for a portable way to define NULL:
>#define NULL (""[1])
>would that work?

No...it would probably generate a nice segment violation as it read off
the end of the array! ;-)

Try:
(""[0]) or even ([0]"") or *("")   (some of these almost look like ;-)

As for portabilty, well, thats why we use #include <stdio.h>. If NULL in
there breaks something...well either fix the code, or the compiler.

Please, don't use your own "portable" versions of NULL as sooner or later it
will break somewhere! And someone (like me) will curse you! ;-) ;-)

Andrew Walduck 
andrew@motto.UUCP (keep trying the mailer is magic!)

mills@ccu.umanitoba.ca (Gary Mills) (09/30/90)

andrew@motto.UUCP (Andrew Walduck) writes:

>Try:
>(""[0]) or even ([0]"") or *("")   (some of these almost look like ;-)

This is equivalent to '\0', which has no relation to NULL.




-- 
-Gary Mills-             -University of Manitoba-             -Winnipeg-