Messages in this thread | | | Subject | Re: bug in socket.h (and maybe many other kernel headerfiles) | From | David Wragg <> | Date | 21 Sep 1999 12:17:35 +0000 |
| |
"Richard B. Johnson" <root@chaos.analogic.com> writes: > The kernel code is written in C. C requires that NULL be defined as > (void *)0. Returning a NULL as a literal 0 is incorrect in C.
Not true. In ANSI/ISO C, a null pointer constant is either an integer constant expression with the value 0, or such an expression cast to void*. NULL expands to an implementation defined null pointer conatant, so both
#define NULL (void*)0
and
#define NULL 0
are suitable, and the latter also meets the C++ standard.
> There > should not be any kernel headers included in an C++ code. Headers that > could be included are protected with conditional statements like: > > #ifndef NULL > #ifdef __cplusplus > #define NULL 0 > #else > #define NULL (void*)0 > #endif > #endif > > This was from <stdio.h>......
That's perfectly correct, and is the traditional definition in order to support pre-standard C compilers, but not strictly necessary on Linux where all the widely and not-so-widely used C compilers support the standard.
David Wragg
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |