Re: Patch for definition of NULL
- From: Tim Janik <timj gtk org>
- To: Kaz Kylheku <kaz ashi footprints net>
- Cc: Raja R Harinath <harinath cs umn edu>, Owen Taylor <otaylor redhat com>, Gtk+ Developers <gtk-devel-list gnome org>, Tim Janik <timj gtk org>
- Subject: Re: Patch for definition of NULL
- Date: Thu, 12 Jul 2001 23:55:20 +0200 (CEST)
On Wed, 11 Jul 2001, Kaz Kylheku wrote:
> A correct definition of NULL is simply 0. That works for C and C++.
> In C, (void *) 0 is also a null pointer constant (and not a pointer
> of type void *, note well), which is a good idea, because it
> traps incorrect uses, where NULL appears in a non-pointer context.
>
> I have no idea why Solaris switches between 0 and 0L; probably someone
> clueless is maintaining the header. A zero-valued integral constant expression
> is a null pointer constant. It doesn't matter if it's long, unsigned
> or whatever. If they have a good reason, correct me.
>
> So if I had to define NULL, I would write:
>
> #ifdef __cplusplus
> #define NULL 0
> #else
> #define NULL ((void *) 0)
> #endif
jup, this is actually what i'd like to see preserved,
NULL evaluating to a pointer expression in C to catch uses
in non-pointer contexts.
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]