Re: weeding out c++ keywords from sys/sys

From: Andriy Gapon <avg_at_icyb.net.ua>
Date: Mon, 16 Feb 2009 10:42:12 +0200
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
Received on Mon Feb 16 2009 - 07:42:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:42 UTC