lkml.org 
[lkml]   [1999]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: bug in socket.h (and maybe many other kernel headerfiles)
From
Date
"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/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.772 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site