NULL vs 0 vs 0L bikeshed time
Mark Murray
mark at grondar.org
Sun Feb 29 07:50:20 PST 2004
Hi
1) Please restrain the need to bikeshed this one to death. I am
sympathetic to technical arguments, but compulsive noise over
such issues is annoying.
2) Please separate style disussion from technical discussion.
I'd like to commit the following patch. It makes sure that for C
and the kernel, NULL is a ((void *)0), and for C++, NULL is either
(0L) or 0, with __LP64__ used to define the difference.
The intent is to catch use of NULL where 0 or (0L) should be used.
It generates extra warnings (I promise to fix these).
Comments?
WARNING! Cut+Paste munging!
Index: _null.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/_null.h,v
retrieving revision 1.5
diff -u -d -r1.5 _null.h
diff -u -d -r1.5 _null.h
--- _null.h 26 Dec 2003 06:11:43 -0000 1.5
+++ _null.h 26 Dec 2003 10:36:52 -0000
@@ -28,14 +28,14 @@
#ifndef NULL
-#ifdef _KERNEL
-#define NULL (void *)0
+#if defined(_KERNEL) || !defined(__cplusplus)
+#define NULL ((void *)0)
#else
#if defined(__LP64__)
-#define NULL 0L
+#define NULL (0L)
#else
#define NULL 0
-#endif
-#endif /* _KERNEL */
+#endif /* __LP64__ */
+#endif /* _KERNEL || !__cplusplus */
#endif
M
--
Mark Murray
iumop ap!sdn w,I idlaH
More information about the freebsd-current
mailing list