[quake3] Re: C++? when did that happen?

Ben Noordhuis bnoordhuis at gmail.com
Sat Oct 8 13:19:29 EDT 2005


On 10/8/05, Ludwig Nussel <ludwig.nussel at suse.de> wrote:
> You cannot blindly replace NULL with 0. sizeof(0) != sizeof(NULL) on
> 64bit platforms. Variadic functions for example will break if you pass 0 where
> you wanted to pass NULL. So always use NULL if you refer to a pointer.

Chapter 5.9 of the C FAQ (http://www.eskimo.com/~scs/C-faq/q5.9.html):

"Many programmers believe that NULL should be used in all pointer
contexts, as a reminder that the value is to be thought of as a
pointer. Others feel that the confusion surrounding NULL and 0 is only
compounded by hiding 0 behind a macro, and prefer to use unadorned 0
instead. There is no one right answer. (See also questions 9.2 and
17.10.) C programmers must understand that NULL and 0 are
interchangeable in pointer contexts, and that an uncast 0 is perfectly
acceptable. Any usage of NULL (as opposed to 0) should be considered a
gentle reminder that a pointer is involved; programmers should not
depend on it (either for their own understanding or the compiler's)
for distinguishing pointer 0's from integer 0's."

Carefully read the last line, please.
Sincerely,

Ben



More information about the quake3 mailing list