Uninitialized externals and statics.

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Aug 25 04:02:31 AEST 1989


In article <7550 at cg-atla.UUCP> fredex at cg-atla.UUCP (Fred Smith) writes:
-It is appropriate when testing a pointer against
-for being the null pointer to do a case, thusly:
-      if (foo == (char *)NULL)
-but then doing such a cast is ALWAYS appropriate, on any machine, since
-right after you leave the company somebody will get the bright idea
-of porting your code to some new whiz-bang-100 processor with weird
-architecture. This is also apprpriate on 8086-class machines, since
-the representation of a pointer, including the null pointer, will vary
-with memory model. (I hate segmented architectures.)

The cast would be necessary only if the implementor has screwed up the
definition of NULL.  #define NULL 0 would always be a correct implementation
definition for NULL, and the cast would never be necessary.  We explain this
in this newgroup every few months..



More information about the Comp.lang.c mailing list