home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / NUL!NULL.TXT < prev    next >
Text File  |  1997-07-05  |  998b  |  24 lines

  1. +++Date last modified: 05-Jul-1997
  2.  
  3. Q: My compiler gives me a warning whenever I try to assign or compare the
  4.    value of NULL to an integral type (char, short, int, long). What's the
  5.    matter?
  6.  
  7.  
  8. A: According to the standard, NULL is a macro defined as a null pointer
  9.    constant so you should expect warnings (at least!) when trying to assign a
  10.    pointer to an integral type without a (highly questionable) cast!
  11.  
  12.    This is a fairly common error since people hear other programmers talking
  13.    all the time about "a null character". As it turns out, ASCII shorthand
  14.    notation for '\0' happens to be NUL, hence the confusion. In SNIPPETS, I
  15.    explicitly work around this common error (in SNIPTYPE.H) with the line...
  16.  
  17.    #define NUL '\0'
  18.  
  19.    The moral of this story is to know the difference between ASCII NUL and C
  20.    NULL, and use whichever is correct for your application. In many cases,
  21.    the correct "null" may be NUL, not NULL.
  22.  
  23.    Is this confusing enough? ;-) 
  24.