From c8a9c22173f485c8c053709e1dfa0a617cb6be1a Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 24 Nov 2013 21:42:55 -0500 Subject: restore type of NULL to void * except when used in C++ programs unfortunately this eliminates the ability of the compiler to diagnose some dangerous/incorrect usage, but POSIX requires (as an extension to the C language, i.e. CX shaded) that NULL have type void *. plain C allows it to be defined as any null pointer constant. the definition 0L is preserved for C++ rather than reverting to plain 0 to avoid dangerous behavior in non-conforming programs which use NULL as a variadic sentinel. (it's impossible to use (void *)0 for C++ since C++ lacks the proper implicit pointer conversions, and other popular alternatives like the GCC __null extension seem non-conforming to the standard's requirements.) --- include/unistd.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/unistd.h') diff --git a/include/unistd.h b/include/unistd.h index a00a9c4f..9f2fac96 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -15,7 +15,11 @@ extern "C" { #define SEEK_CUR 1 #define SEEK_END 2 +#ifdef __cplusplus #define NULL 0L +#else +#define NULL ((void*)0) +#endif #define __NEED_size_t #define __NEED_ssize_t -- cgit v1.2.1