C++ warnings from system header 'socketbits.h' : can we clean this up?

Ron Flory (ron.flory@ifrsys.com)
Fri, 12 Mar 1999 10:34:19 -0600


Hi all-

There is a little problem with the system networking header file
/usr/include/socketbits.h (which is brought in by socket.h) such
that it cannot be included in a C++ program without causing
warnings that should not be present from system headers. Simply
using 'extern "C"' will not it.

Basically the problem is due to an old C hack where folks
assume the macro NULL evaluates to 0. In C++ NULL is defined
as '(void*) 0' which is quite distinct from zero, and may not
be freely converted to an integer.

Here's the gcc output:

/usr/include/socketbits.h: In function `struct cmsghdr *
__cmsg_nxthdr(struct msghdr *, struct cmsghdr *)':
In file included from /usr/include/sys/socket.h:34,
from connect.cxx:8:
/usr/include/socketbits.h:204: warning: ANSI C++ forbids implicit
conversion from `void *' in return
/usr/include/socketbits.h:213: warning: ANSI C++ forbids implicit
conversion from `void *' in return

The 'diff' output to correct the problem follows:

204c204
< return NULL;

---
>     return 0;
213c213
<     return NULL;
---
>     return 0;

Thanks,

ron flory

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/