C++11 Compiler: Closest to the standard and how close? - c++

I'm interested in learning C++ more thoroughly now that C++11 is apparently ratified. What compiler currently implements the closest thing available to full C++11 support? How close is said compiler to full support? Are there still major features missing or just language lawyer minutiae?

There's a support matrix on the Apache wiki.

I think the one Scott Meyers maintains on his homepage is pretty good:
http://www.aristeia.com/C++0x/C++0xFeatureAvailability.htm

The llvm C++ compiler "clang" has partial C++11 support; you can see its current state at http://clang.llvm.org/cxx_status.html.

There's also GCC C++0x (or C++11) status page : http://gcc.gnu.org/projects/cxx0x.html

IBM's xlC++ compiler has a basic C++11 feature support page.

To anyone reading this now, as of Jan 2013 Clang 3.2 is probably the most complete C++11 compiler, although the latest dev branch of GCC (4.8.x) is going to bring GCC back on par by the looks of it.
http://clang.llvm.org/cxx_status.html
Just look at that support table! Epic stuff. That's only accounting for currently available stable versions as well whereas the GCC table contains some 4.8 entries.
Like I said though, when GCC 4.8 hits stable release, it's going to be tight between the two again:
http://gcc.gnu.org/projects/cxx0x.html

Related

Some troubles with compiler mingw_w64

Yesterday I started making some project and today I check out that my compiler (mingw_w64) is the newest one which I find in Internet (8.1) but I don't have all functions from C++20. So maybe someone know how to figure out this? If it somehow help my IDE is QT creator.
C++ ISO standards and compilers do not progress at the same pace or with the same priorities. Also, C++ standards are available (drafts) before they are complete or officially published: quite often, compilers partially support the draft specs. The good side of this is that there are tables telling you what feature of a given standard is supported by a given version of GCC. You can find such a table for GCC here.
The current latest release of GCC is GCC 11 and C++20 support has been available since GCC 10.
Another compiler is LLVM/Clang, but I don't believe their C++20 support is on the same level as GCC yet, though I excpect it to catch up soon.
Get the latest MinGW-w64 GCC build from: http://winlibs.com/

Are extensions for parallelism going to be available for the new C++17 Standard?

First of all, C++17 changes are listed in this post. Today I downloaded clang to check if it was complete for C++17 (as gcc hasn't implemented everything yet), and here you can read:
Clang 5 and later implement all the features of the C++ 2017 Draft International Standard.
You can use Clang in C++17 mode with the -std=c++17 option (use -std=c++1z in Clang 4 and earlier).
Then, I assume that all features of C++17 have been added in clang 5.0, but checking all of them, I couldn't find the extensions for parallelism of stl algorithms and so on. I tried adding the header <execution> to test the new feature, but nothing seems to work.
I'm suspencting that this feature "maybe" won't be available, but I'm not sure because there's almost no information about it.
I think Intel implemented something in its compiler, but I'm not really into it since I use Linux.
Are extensions for parallelism going to be available for the new C++17 Standard?
Yes, extensions for parallelism have been merged into the ISO C++ Standard.
Clang 5 and later implement all the features of the C++ 2017 Draft International Standard.
This seems to refer only to core language features. You probably want to check the libc++ and/or libstdc++ conformance status instead.
https://libcxx.llvm.org/cxx1z_status.html
https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html
In the above links, P0024 is not marked as implemented.

C++11 features compatibility with different versions of GCC

Following, my previous question about How to safely deploy an application built with an upgraded compiler, there is still a doubt for me about the C++11 features compatibility. Using devtoolset-2, the application that will be built with gcc 4.8.2 but linked with libstdc++.so.6.0.13 will have full C++11 features supported or only the common set with libstdc++6.0.19 ?
I am not really sure to understand this point actually.
You shouldn't be mixing libstdc++ like that, so it's a moot point. You should redistribute the libstdc++ that comes with devtoolset-2 and link against that specifically. Otherwise the compiler and standard library will be at odds with each other, and even they won't know the answer to your question!
Then, simply look up a list of what C++11 features are supported in GCC 4.8.2.

Which gcc version is needed to use unordered_map from C++11?

I am currently on RHEL 5.4 with gcc 4.1 installed, but I want to use unordered_map. As I found out, this is only introduced in C++11 to the standard, and therefore not available. One alternative would be using __gnu_cxx::hash_map, but I would prefer using standards.
On another development host I happend to have RHEL 6.4 and gcc 4.4, which knows unordered_map, but gives the following warning:
../include/c++/4.4.7/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
From the gcc homepage I can't seem to find out which gcc version supports unordered_map.
[edit]
To clarify my question:
I am stuck to several operating systems and their versions by customer requirements, therefore I cannot always update to the latest GCC version and be happy. I need to maintain compatibility of my software across all platforms.
I am therefore searching for the minimum GCC version required to use unordered_map. I am aware of the fact that supplying -std=c++0x to GCC fixes the error above, but I dont know how far the "experimental" warning means I should not be using unordered_map.
Some guys in this thread strongly advise not to use this experimental C++11 implementation
... so what should I do?
You cannot find such information on the GCC page. There is information about library features, but only about current version of GCC. In your GCC 4.4, you can simply use -std=c++0x flag to remove the warning.
If you are scared about experimental and cannot update the compiler - just don't use unordered_map from C++11. You can write your own, use one from tr1, or use the one from boost, no matter.
If you just look at GCC site - there is message there:
Important: GCC's support for C++11 is still experimental. Some
features were implemented based on early proposals, and no attempt
will be made to maintain backward compatibility when they are updated
to match the final C++11 standard.
By the way, all features of the C++11 standard are realized in GCC, it's actually old standard, since now C++14 is already approved, but support is still expiremental.
I have no idea WHY it's still experimental, for example on clang site:
Clang fully implements all published ISO C++ standards including
C++11, as well as the upcoming C++14 standard, and some parts of the
fledgling C++1z standard, and is considered a production-quality C++
compiler.
And only C++1z support is experimental.
You should upgrade to gcc 4.9.2, if you can. Otherwise use gcc 4.4. They'll both need the -std=c++0x option.

Can I use C++11 with Xcode?

I am considering the use of some C++11 features (like auto for instance) in some cross-platform projects (Windows+Mac). On Windows, Visual Studio supports parts of the upcoming C++11 standard that would allow me to simplify parts of the code base so naturally I would be interested in starting to use these features.
But as far as I am aware, the current XCode version (3.2.4 + GCC 4.2) does not support any C++11 features at all. Can I upgrade the GCC version or the CLang version somehow? Or should I just bite my tongue and wait for Apple to package a new version sometime in the future?
Xcode 4.2 had finally added support for C++0X:
In the project build settings screen, switch on "All" options.
In the "Build Options" section, set compiler to "Apple LLVM compiler 3.0".
Scroll down to "Apple LLVM Compiler 3.0 - Language" section and set "C++ Language Dialect" to "C++0X" and "C++ Standard Library" to "libc++".
The std::move(), move constructor and R-Value reference are known to work as expected, and I'm testing on the std::thread and std::atomic.
======= Update 2012: =======
Start with Clang - Many C++11 features are now available in Clang. It's included with Xcode.
======= Original answer from Jan 2011: =======
intel's compiler may be the cleanest way to go at this time.
http://software.intel.com/en-us/articles/intel-composer-xe/
clang's promising, but not particularly stable or featured wrt c++0x features. c++ is still very new for clang.
gcc: relatively mature, but you'll have to write and maintain your compiler plugins for xcode.
you can also specify custom scripts, but that is a pain to maintain... unless you go all out and create an adaptor tool.
Xcode uses the GCC or the Clang C++ compilers. Any features supported by those compilers are fair game. GCC's C++ compatibility page is here and the Clang C++ compatibility page is here.
I've found auto, decltype(), range based "for (:)" work in a cross platform project (LLVM for MacOSX,iOS, gcc/linux, MSVC 10/windows).
lambdas & variadic macros don't appear to work under LLVM yet sadly.