Re: Paying developers to get features faster

From: Baho Utot (baho-utot_at_philippines-island.org)
Date: 01/25/04


Date: Sun, 25 Jan 2004 00:01:03 GMT

Måns Rullgård wrote:

> Brad Olin <bwo@bwo1.com> writes:

>> The one time that I have actually seen when the traditional "if (<var>)"
>> test was an invalid test was a case of a pointer that should have been
>> compared to NULL. i.e "if (<var> != NULL)" vrs "if (<var>)". I tracked
>> this case down into a third party library that re-defined NULL to a
>> non-zero value. I'm not a complete ANSI C guru, but I think that NULL
>> is a notion of invalid and not guaranteed to be zero.
>
> Yes, it's something like that. However, the standard does specify
> that a NULL pointer value used as a truth value must be false. Thus,
> your particular setup was not ANSI C compliant.
>

But if you compare to an unadorned 0 it is garranteed to work. I believe
using NULL for a pointer comparison is nothing more than a crutch.



Relevant Pages

  • Re: Paying developers to get features faster
    ... >> test was an invalid test was a case of a pointer that should have been ... > that a NULL pointer value used as a truth value must be false. ... using NULL for a pointer comparison is nothing more than a crutch. ...
    (comp.os.linux.development.system)
  • Re: Paying developers to get features faster
    ... >> test was an invalid test was a case of a pointer that should have been ... > that a NULL pointer value used as a truth value must be false. ... using NULL for a pointer comparison is nothing more than a crutch. ...
    (comp.security.misc)
  • Re: Paying developers to get features faster
    ... >> test was an invalid test was a case of a pointer that should have been ... > that a NULL pointer value used as a truth value must be false. ... using NULL for a pointer comparison is nothing more than a crutch. ...
    (comp.os.linux.misc)
  • Re: Problem with STL
    ... forget about char* comparison, pointer comparison is most appropriate! ... bool operator(char const* lhs, char const* rhs) const ...
    (microsoft.public.dotnet.languages.vc)
  • Re: direction of stack growth
    ... of pointer comparison when the pointers point into the same array, ... object as its element type. ...
    (comp.lang.c)

Quantcast