Portable NULL pointers

Andrew Walduck andrew at motto.UUCP
Fri Sep 28 03:42:46 AEST 1990


goudreau at dg-rtp.dg.com (Bob Goudreau) writes:
>> The Second Original Sin was the failure to make "NULL" a keyword.
roy at 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 at motto.UUCP (keep trying the mailer is magic!)



More information about the Comp.lang.c mailing list