Re: NULL macro vs. 0 as null pointer?
From: Julie (julie_at_nospam.com)
Date: 07/23/04
- Next message: Ken: "Followup: NULL macro vs. 0 as null pointer?"
- Previous message: Andre Kostur: "Re: NULL macro vs. 0 as null pointer?"
- In reply to: Ken: "NULL macro vs. 0 as null pointer?"
- Next in thread: Rolf Magnus: "Re: NULL macro vs. 0 as null pointer?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 23 Jul 2004 09:01:28 -0700
Ken wrote:
>
> Hi all. When referring to a null pointer constant in C++, is there
> any reason to prefer using 0 over a macro called NULL that is defined
> to be 0?
There is no right answer, and from an 'enforcement' standpoint, you will only
cause problems.
If you are simply asking for yourself, you will need to decide what suits you
best.
The general thoughts are:
- NULL can make it more clear in the code that you are expecting and dealing
with pointers, but NULL is not part of the language proper, but part of the
library (meaning that you must include a library before it is defined).
- 0 requires no support library (i.e. it is part of the language proper), but
it can lead some loss of code clarity when dealing w/ pointers (specifically
integer pointers, is the intent to compare the pointer or the destination of
the pointer?)
- Next message: Ken: "Followup: NULL macro vs. 0 as null pointer?"
- Previous message: Andre Kostur: "Re: NULL macro vs. 0 as null pointer?"
- In reply to: Ken: "NULL macro vs. 0 as null pointer?"
- Next in thread: Rolf Magnus: "Re: NULL macro vs. 0 as null pointer?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|