[cfe-dev] How to control C++0x adoption in a large codebase?

John McCall rjmccall at apple.com
Wed Oct 5 17:18:03 PDT 2011


On Oct 5, 2011, at 5:12 PM, Howard Hinnant wrote:
> On Oct 5, 2011, at 8:05 PM, John McCall wrote:
>> On Oct 5, 2011, at 4:44 PM, Jeffrey Yasskin wrote:
>>> On Wed, Oct 5, 2011 at 4:30 PM, John McCall <rjmccall at apple.com> wrote:
>>>> On Oct 5, 2011, at 3:35 PM, Jeffrey Yasskin wrote:
>>>>> I'm working on migrating a certain large codebase to C++0x, and we're
>>>>> looking for a way to turn on C++0x mode but make sure people don't use
>>>>> C++0x features before we're ready for them.
>>>>> 
>>>>> * We need to turn on -std=gnu++0x for the whole codebase at once
>>>>> because C++98 and C++0x have different ABIs.
>>>> 
>>>> As far as I'm aware, this is not really true, and I actually put a lot of
>>>> effort into fighting a few committee proposals that would have forced
>>>> ABI changes.  There are a few things like name mangling which have been
>>>> changed/clarified in the Itanium ABI, and obviously the standard library
>>>> has to export more symbols in '0x, but I don't know of well-formed '03
>>>> programs that have changed.
>>> 
>>> http://gcc.gnu.org/PR45093 concludes that the libstdc++ maintainers
>>> don't intend to maintain binary compatibility between the two language
>>> versions. It certainly may be that it would have been possible to
>>> maintain compatibility, but they didn't, so that's what we have to
>>> live with. libc++ probably does this better, but we don't really want
>>> to block constrained C++0x support on switching to that either.
>> 
>> Okay.  Just wanted to make sure you weren't talking about some
>> core-language thing I'd missed.  I believe Howard has, in fact, designed
>> libc++ with cross-dialect binary compatibility in mind, although obviously
>> he's been assisted in that by being able to design with foreknowledge
>> of C++0x's requirements.
>> 
>> John.
> 
> libc++ uses C++11's inline namespace to version the ABI between gcc's C++03 std::lib and libc++.  This translates to a /noisy/ ABI incompatibility as gcc::std::vector and libc++::std::vector have different manglings (you get your errors at link time instead of run time).  Although some ABI's have been maintained as compatible:  std-defined exception classes, operator new/delete, handler functions.

By "cross-dialect" I meant C++03 vs. C++11.  Assuming that the libc++ library itself is compiled in C++11 mode, C++03 code using libc++ should interoperate with C++11 code using libc++, correct?

John.



More information about the cfe-dev mailing list