[ale] C++, sockets, 2.2.12

Benjamin Scherrey scherrey at switchco.com
Thu Oct 7 13:17:07 EDT 1999


Joe,

	I noticed that there was some discussion about this issue in the egcs
developers email list but now I can't find it in my saved messages.
Anyway, you should be able to use -fpermissive (I gave you the wrong
one previously) as a compiler switch to allow Cfront type behaviour
which should allow that void* cast to occur. It is an error in the
header files and I believe it will be changed in the short future.
ANSI C and C++ both support defining NULL as 0 instead of (void*)0.
That is most probably your problem cause the old header files define
it as (void*)0 as you have already discovered.

	good luck,

		Ben Scherrey

PS: Where do you work and what kind of development are you doing?

Joe Knapka wrote:
> 
> Hi, Ben,
> 
> The function in question is defined inline in include/linux/sockets.h
> (which is naturally a symlink from /usr/src/linux/include...), and
> looks like this in general form (I don't have the code in front of
> me at the moment):
> 
> struct cmsghdr* __cmsg_nxthdr(...) {
>   try_somthing();
>   if (it worked) return &some_actual_cmsghdr;
>   else return NULL; /* Compile error here - NULL == (void*)0. */
> }
> 
> I hacked around it by editing the kernel header :-P and changing
> the NULL to (struct cmsghdr*)0. I haven't been searching for
> a solution, so that's where things stand. I just installed
> the 2.3.18 kernel, so I should probably try building this
> stuff again... but not tonight. (Urk, just looked - same
> problem in 2.3.18.) I am never calling this function in my
> code - it's just defined here, presumably for the kernel's
> use. Which sucks, IMHO.
> 
> Of course, when compiling plain C code this isn't a problem,
> but since C++ prohibits implicit conversions from void*
> to anything else, BOOM!
> 
> Thanks,
> 
> -- Joe
>






More information about the Ale mailing list