weeding out c++ keywords from sys/sys

Andriy Gapon avg at icyb.net.ua
Mon Feb 16 00:42:34 PST 2009


on 16/02/2009 08:07 Andrew Reilly said the following:
> On Sun, Feb 15, 2009 at 07:11:58PM +0100, Christoph Mallon wrote:
>> Michael Butler schrieb:
>>> .. stops C++ from mangling the prototyped functions so they'll link
>>> correctly but does it temporarily disable the "reserved word" tests?
>>> Should it? ;-)
>> No, it doesn't. extern $STRING (the standard only requires "C" and 
>> "C++", but there can be more) just changes the linkage of declarations 
>> (name mangling, calling convention).
> 
> I've always wondered: why does the extern "C" {} cruft have to
> be pushed into all C headers, rather than being wrapped around
> the #include <> lines in the C++ source that includes them?
> Then you wouldn't need the #ifdef __cplusplus conditional,
> because you already know that it's C++ code.  Common usage seems
> to have it backwards, but I assume that there must be a reason.
> 

Since this thread has already strayed beyond the original topic, I now 
feel free to participate in it again.
I think that there are two approaches.
Current C++ code for our kernel does exactly what you say - puts extern 
C around inclusion of system headers.
But if someone decides to purposefully provide C headers that are both C 
and C++ -friendly, then they typically put conditional extern into the 
headers. I wouldn't suggest doing that to FreeBSD headers though (yet).

-- 
Andriy Gapon


More information about the freebsd-current mailing list