3

As of right now may 23 2012, I want to start coding with C++11 and use it in all my projects, cuz I see many new features I really like. But, none of the compilers I have support anything from C++11. Can anyone suggest some books and compilers? Is it a good idea to use c++11 in my projects? Does qt creator 2.5 support c++11?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
user52343
  • 773
  • 1
  • 7
  • 19
  • 1
    g++ 4.7 supports a lot of [the main] C++11 features. – Seth Carnegie May 23 '12 at 18:02
  • 1
    Check the [c++11 tag wiki](http://stackoverflow.com/tags/c%2b%2b11/info). Currently the two compilers with the most support for C++11 features are GCC 4.7 and Clang 3.1 (released yesterday). – R. Martinho Fernandes May 23 '12 at 18:03
  • 2
    Ask yourself whether you need portability of your source code. This will affect your decision. – Paul Beckingham May 23 '12 at 18:53
  • It should be noted that if you need to write portable code, you'll need to be very judicious about your usage of C++11 features. These features are new, which means they are not well-tested (relative to the features of C++98/03). All compilers have lots of bugs with these new features (including gcc 4.7 and clang 3.1). – James McNellis May 23 '12 at 19:08
  • C++11 book: http://stackoverflow.com/a/10099211/1170277 – mavam May 24 '12 at 05:23

2 Answers2

14

Your choice of compilers will depend on the platform you're developing for.

Gcc 4.7 and Clang seem to support the most C++11 features but I think their Windows support is mostly limited to mingw and I believe clang is limited even there. Intel C++ doesn't have as much C++11 support as gcc or clang, but more than VC++ and it supports Windows well. VC++ 11 is a great compiler and has great Windows support, but unfortunately it's at the back of the pack today with regard to C++11 features, missing variadic templates, initializer lists and uniform initialization, user-defined literals, constexpr, the new string literals, defaulting/deleting functions, delegating/inheriting ctors, template type aliases, etc.

If you're targeting Linux then gcc obviously has great support for that, and clang isn't too far back I don't think. If you're targeting a BSD or OS X then Clang is the obvious choice.

If you're targeting multiple platforms then you'll just have to limit yourself to the subset of C++11 that works on all your compilers.

C++11 compiler support: http://wiki.apache.org/stdcxx/C%2B%2B0xCompilerSupport


C++11 books have just started to come out. There's a new edition of The C++ Standard Library: A Tutorial and Reference. C++ Concurrency In Action covers the new memory model, multi-threading, and atomics stuff pretty thoroughly. As far as I'm aware those are the only ones so far. There are plenty of articles and things available online though, which ought to be sufficient to get started:

Articles and papers

Conferences


It's a great idea to use C++11, so long as lack of support doesn't prevent you from doing so.


Qt Creator 2.5 does have some support for C++11: http://labs.qt.nokia.com/2012/03/15/qt-creator-2-5-beta/

bames53
  • 86,085
  • 15
  • 179
  • 244
  • +1 Very thorough and well written. Very pleasant read, thank you. – Drise May 23 '12 at 20:40
  • Visual C++ has pretty good C++11 support in the Visual Studio 11 Beta, including a largely complete C++11 standard library implementation with thread, atomic, etc. – mattnewport May 24 '12 at 00:57
  • @mattnewport VC++ 11 is a great compiler, but unfortunately it's fallen behind other compilers in terms of C++11 support. It was one of the first to get lambdas, auto, and rvalue references. But now the other compilers have surpassed it with initializer lists, variadic templates, constexpr, the new string literals, and many other C++11 features. The VC++ library is nice though, with some things not in gcc's library. clang's library is I think completely complete, and I'm not sure about the other compilers. – bames53 May 24 '12 at 05:00
0

I got a gcc 4.7 binary from http://nuwen.net/mingw.html and that lets me use most of the C++11 features. It was incredibly easy to install and set up (I use Code::Blocks 10.05 on Windows 7). The only minor problem was that it didn't come with gdb, but that was easy to find, download and install.

sednihp
  • 19
  • 1
  • 2