From e52881724836a9ab70a5f76354ec77cbbd94aeb1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 30 Aug 2015 23:10:39 +0200 Subject: null considered harmful considered harmful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/stddef.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/stddef.h b/include/stddef.h index 275e53c..0e10989 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -28,6 +28,18 @@ * the same width and ISO C does not specify it this * way), use to indicate that a pointer does not point * to anything. + * + * Note on considerations of `NULL` being harmful: + * It is important to remember than `sizeof(NULL)` + * does not equal `sizeof(int)` on all machines. + * Therefore, in variadic arguments, it is important + * not to substitute `x` for `x != NULL`. This + * would cause horrible bugs. If you insist on not + * using `NULL`, correct substitutions would be + * `!!x` or `x != 0`. + * Note that `NULL` is genuinely harmful in C++, + * but excessive use of C++, and especially it + * features, is harmful too. */ #ifndef NULL # define NULL ((void*)0) -- cgit v1.2.3-70-g09d2