[cfe-dev] [libcxx] RFC: C++14 and beyond

Chris Lattner clattner at apple.com
Thu May 2 10:46:01 PDT 2013

On May 2, 2013, at 6:50 AM, Howard Hinnant <hhinnant at apple.com> wrote:

> libcxx was begun as a C++11 (then called C++0x) library.  It never even tried to adhere to the C++03 specification, though it does endeavor to work in C++03 language mode.
> Now we have a working draft for C++14 and certainly libc++ needs to support C++14.  However not all C++14 changes are 100% API compatible with C++11 (just like there are a few API breakages between C++03 and C++11).  For example John Spicer demonstrated the following example which shows that you can silently impact run time behavior by adding constexpr to a function.

Just MHO:

You should clearly use some sort of macro to control the behavior of the headers, and (to support future standards) it should be something like __cplusplus that is defined to a number.

A harder question is: how should this be surfaced by the clang driver?  I don't think it makes sense to force people to pass a -D flag to control this.  This is the sort of thing that should have driver support.  It seems that we could:

1) implicitly tie it to the language setting (i.e., use __cplusplus directly) which is simple, but limiting, and goes against how libc++ works with '98 and '11.
2) add a new option, like "-stdlib-version=14" (or something hopefully better)
3) tie it into the -stdlib option, so you could use -stdlib=libc++14 or something.

Given that most people will generally want to use libc++'14 support with C++'14 language support, perhaps the right option is a hybrid of #1 and #2.  We could have __cplusplus set the default mode for the library, but then add the new option which would let people override it in the uncommon case where they want C++'14 language but C++'11 library support.

What do you think?


More information about the cfe-dev mailing list