Re: if (blah) ...

From: George Greer (greerga@circlemud.org)
Date: 08/12/99


On Thu, 12 Aug 1999, Daniel A. Koepke wrote:

>Today, Oleg V. Volkov spake to the list:
>
>> Why?!
>> Could you supply at least one example where replacing if (blah) with
>> if (blah != NULL) give different results?
>
>Well, if 'blah' isn't a pointer then they are different.

/usr/include/libio.h:

# if defined __GNUG__ && \
    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
#  define NULL (__null)
# else
#  if !defined(__cplusplus)
#   define NULL ((void*)0)
#  else
#   define NULL (0)
#  endif
# endif
#endif

If you use GCC 2.7.2.3, then they'll be the same, otherwise they won't be.
Since he's using GCC 2.95 (I believe, haven't been following thread),
Daniel is correct that an non-pointer will behave differently.

--
George Greer            | Mailing list archives
greerga@circlemud.org   | http://post.queensu.ca/~listserv/wwwarch/circle.html


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST