Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2009 10:42:12 +0200
From:      Andriy Gapon <avg@icyb.net.ua>
To:        Andrew Reilly <andrew-freebsd@areilly.bpc-users.org>
Cc:        Christoph Mallon <christoph.mallon@gmx.de>, Michael Butler <imb@protected-networks.net>, Bruce Simpson <bms@incunabulum.net>, freebsd-current@freebsd.org
Subject:   Re: weeding out c++ keywords from sys/sys
Message-ID:  <499926E4.3060207@icyb.net.ua>
In-Reply-To: <20090216060716.GC70145@duncan.reilly.home>
References:  <4995BB1B.7060201@icyb.net.ua> <20090213231513.GA20223@duncan.reilly.home> <4997F105.5020409@icyb.net.ua> <499811DF.6030905@incunabulum.net> <20090215151318.0d17bfb9@ernst.jennejohn.org> <49983868.5010107@incunabulum.net> <20090215182420.774b90c3@ernst.jennejohn.org> <49985807.805@protected-networks.net> <49985AEE.1010709@gmx.de> <20090216060716.GC70145@duncan.reilly.home>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?499926E4.3060207>