changeset 21490:a2cca53d71d2

lib: Make sure NULL is defined to be ((void *)0) This avoids us having to do explicit (void *)NULL casts in e.g. io_add(..., NULL) context parameter.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 06 Feb 2017 10:55:40 +0200
parents 3309fe3ea47b
children c130a08ebbaf
files src/lib/compat.h
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/compat.h	Sat Feb 04 13:51:13 2017 +0200
+++ b/src/lib/compat.h	Mon Feb 06 10:55:40 2017 +0200
@@ -11,6 +11,13 @@
 #  define LLONG_MAX 9223372036854775807LL
 #endif
 
+/* We really want NULL to be a pointer, since we have various type-checks
+   that may result in compiler warnings/errors if it's not. */
+#ifndef __cplusplus
+#  undef NULL
+#  define NULL ((void *)0)
+#endif
+
 #ifndef __cplusplus
 #ifdef HAVE__BOOL
 typedef _Bool bool;