As pointed out by Richard Guenther our definition
of NULL will be incorrect for c++ compilers that aren't
gcc (or pretend to be gcc like clang).

Index: dirent.h
===================================================================
RCS file: /cvs/src/include/dirent.h,v
retrieving revision 1.21
diff -u -p -r1.21 dirent.h
--- dirent.h    6 Apr 2011 11:39:42 -0000       1.21
+++ dirent.h    2 Jul 2011 07:18:49 -0000
@@ -84,6 +84,8 @@ typedef struct _dirdesc {
 #ifndef NULL
 #ifdef         __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif /* __GNUG__ */
Index: locale.h
===================================================================
RCS file: /cvs/src/include/locale.h,v
retrieving revision 1.7
diff -u -p -r1.7 locale.h
--- locale.h    6 Apr 2011 11:39:42 -0000       1.7
+++ locale.h    2 Jul 2011 07:18:49 -0000
@@ -59,6 +59,8 @@ struct lconv {
 #ifndef NULL
 #ifdef         __GNUG__
 #define NULL   __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: stddef.h
===================================================================
RCS file: /cvs/src/include/stddef.h,v
retrieving revision 1.11
diff -u -p -r1.11 stddef.h
--- stddef.h    6 Apr 2011 11:39:42 -0000       1.11
+++ stddef.h    2 Jul 2011 07:18:49 -0000
@@ -67,6 +67,8 @@ typedef       __mbstate_t     mbstate_t;
 #ifndef        NULL
 #ifdef         __GNUG__
 #define NULL   __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: stdio.h
===================================================================
RCS file: /cvs/src/include/stdio.h,v
retrieving revision 1.39
diff -u -p -r1.39 stdio.h
--- stdio.h     6 Apr 2011 11:39:42 -0000       1.39
+++ stdio.h     2 Jul 2011 07:18:49 -0000
@@ -58,6 +58,8 @@ typedef       __off_t off_t;
 #ifndef NULL
 #ifdef         __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: stdlib.h
===================================================================
RCS file: /cvs/src/include/stdlib.h,v
retrieving revision 1.48
diff -u -p -r1.48 stdlib.h
--- stdlib.h    6 Apr 2011 11:39:42 -0000       1.48
+++ stdlib.h    2 Jul 2011 07:18:49 -0000
@@ -80,6 +80,8 @@ typedef struct {
 #ifndef        NULL
 #ifdef         __GNUG__
 #define NULL   __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: string.h
===================================================================
RCS file: /cvs/src/include/string.h,v
retrieving revision 1.21
diff -u -p -r1.21 string.h
--- string.h    6 Apr 2011 11:39:42 -0000       1.21
+++ string.h    2 Jul 2011 07:18:49 -0000
@@ -46,6 +46,8 @@ typedef       __size_t        size_t;
 #ifndef        NULL
 #ifdef         __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: time.h
===================================================================
RCS file: /cvs/src/include/time.h,v
retrieving revision 1.19
diff -u -p -r1.19 time.h
--- time.h      6 Apr 2011 11:39:42 -0000       1.19
+++ time.h      2 Jul 2011 07:18:49 -0000
@@ -47,6 +47,8 @@
 #ifndef        NULL
 #ifdef         __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: unistd.h
===================================================================
RCS file: /cvs/src/include/unistd.h,v
retrieving revision 1.63
diff -u -p -r1.63 unistd.h
--- unistd.h    6 Apr 2011 11:39:42 -0000       1.63
+++ unistd.h    2 Jul 2011 07:18:49 -0000
@@ -58,6 +58,8 @@
 #ifndef NULL
 #ifdef         __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif
Index: wchar.h
===================================================================
RCS file: /cvs/src/include/wchar.h,v
retrieving revision 1.17
diff -u -p -r1.17 wchar.h
--- wchar.h     1 Jun 2011 16:39:07 -0000       1.17
+++ wchar.h     2 Jul 2011 07:18:49 -0000
@@ -65,6 +65,8 @@
 #ifndef        NULL
 #ifdef __GNUG__
 #define        NULL    __null
+#elif defined(__cplusplus)
+#define        NULL    0L
 #else
 #define        NULL    ((void *)0)
 #endif

Reply via email to