Re: What is the advantage of "NULL == pMyPointer" instead of "pMyPointer == NULL"?

From: Pete Becker (petebecker_at_acm.org)
Date: 04/09/04


Date: Fri, 09 Apr 2004 10:27:07 -0400

Rob Vermeulen wrote:
>
> In several SDK examples of MS I notice the following.
> To compare a pointer with NULL they do: "NULL == pMyPointer"
> Why not just the other way around, like every "C++ for dummies" book
> describes? :-)
>

Some people worry that they might leave out the second '=' sign and that
their testing isn't adequate to find such a mistake. Writing the test
backwards turns this mistake into an error.

-- 
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)


Relevant Pages

  • Re: Your opinions sought
    ... I try not to let it worry me as I know if i make a mistake or an accident ... government needs to promote this. ...
    (uk.rec.scouting)
  • Re: blind man fined
    ... couple that if a mistake has been made they have nothing to worry about. ... It's Humberside Police. ... They make the Keystone Kops look competent. ...
    (uk.rec.driving)
  • Re: JSHs mistakes happen all the time
    ... That should be Southwest Journal of Pure and Applied Mathematics. ... > Interesting that the poster didn't point out that little mistake. ... Don't worry about it. ... Your small mistake was inconsequential. ...
    (sci.math)
  • Re: aygshell.h missing in WinCE6.0 SDK
    ... I think everybody is missing the point: ... So, what he's saying is that HE doesn't try to use aygshell.h, but the standard afxce.h file is trying to include it. ... If afxce.h only *includes* (by mistake) but does not *use* any of the functions in aygshell.h, then the CE 5.0 mistake of falsely always including aygshell.h in the SDK will cover up this 2nd mistake of always including aygshell.h in afxce.h. ... CE 6.0 did get the SDK right by not including aygshell.h in the SDK if it wasn't added as a component to the image, but now the other mistake becomes visible. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: RAM problem
    ... Don`t worry, I`ve heard the same from others, so you`re not the only one to ... make that mistake. ... and only on some systems that support hot swapping, doing so with RAM ... modules or PCI cards in most cases will lead to permanent hardware damage. ...
    (microsoft.public.windowsxp.hardware)