netdev
[Top] [All Lists]

Re: ANSI C++ problem in include/linux/socket.h

To: "Benjamin C.R. LaHaise" <blah@xxxxxxxxx>, torvalds@xxxxxxxxxxxxx
Subject: Re: ANSI C++ problem in include/linux/socket.h
From: OKUJI Yoshinori <okuji@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Nov 1999 17:42:56 +0900
Cc: netdev@xxxxxxxxxxxxxxx
In-reply-to: <Pine.LNX.3.96.991110021557.21637C-100000@kanga.kvack.org>
References: <19991108072259J.okuji@kuicr.kyoto-u.ac.jp> <Pine.LNX.3.96.991110021557.21637C-100000@kanga.kvack.org>
Sender: owner-netdev@xxxxxxxxxxx
From: "Benjamin C.R. LaHaise" <blah@xxxxxxxxx>
Subject: Re: ANSI C++ problem in include/linux/socket.h
Date: Wed, 10 Nov 1999 02:18:22 -0500 (EST)

> Wrong fix.  The include files in 2.2.12+ are careful to define NULL as 0
> when compiling C++ code, so something else you are #include'ing is
> redefining NULL as ((void *)0) instead of the 0 it's supposed to be.

  Thanks for pointing out that. I read and tested all the NULL
definitions, and then found that "include/linux/posix_types.h" was the
cause. The header unconditionally defines NULL as "(void *)0". So this
is a revised patch (I don't know where to send it, so I add Linus into
the addresses):

--- linux/include/linux/posix_types.h   Mon Dec 28 15:18:28 1998
+++ /usr/src/linux/include/linux/posix_types.h  Wed Nov 10 17:30:19 1999
@@ -8,7 +8,11 @@
  */
 
 #ifndef NULL
-# define NULL          ((void *) 0)
+# if !defined __cplusplus
+#  define NULL         ((void *) 0)
+# else
+#  define NULL         (0)
+# endif
 #endif
 
 /*

----------------------------------------------------------------------
OKUJI Yoshinori  <okuji@xxxxxxxxxxxxxxxxxxx>           ^o-o^
http://duff.kuicr.kyoto-u.ac.jp/~okuji (in English)     m /

<Prev in Thread] Current Thread [Next in Thread>