22

I'm wondering how well writing software in C++11 works on Windows yet. It would be most comfortable (and propably most natural) to use one of the native compilers for Windows - I'm thinking about Visual Studio 2012 Express or Visual Studio 2013 Express here. Everything I could find so far on that matter is

  1. http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx (Comparison of C++11 features of VC10 and VC11, which seems to be quite bad)
  2. http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx (not really transparent, didn't give me a good idea how well it works)

Does anyone have any experience how well the current Visual Studio versions can handle C++11? I really want to start using auto, lambdas, variadic templates, template aliases, initializer lists and rvalue references (to name just a few) and all the other good stuff right now, but if Windows might be a problem I might have to use C++03 further.

Another possibility seems to be to install LLVM and Clang on Windows. My primary platform is OSX, and on that system Clang's support for C++11 is really good. But I read that the LLVM-version of the standard library for C++ (libc++) does not work well on Windows. So LLVM/clang might not be an option.

What are your opinions on C++11 development on Windows?

Thank you!

Sh4pe
  • 1,800
  • 1
  • 14
  • 30
  • *"I really want to start using auto, lambdas ..."* -- Visual Studio has supported both of those since v10. What else do you want to use? – Benjamin Lindley Aug 13 '13 at 15:16
  • I just named two features that came to my mind first. The table in link # 1. I posted gives me the impression that v10 and v11 are not yet able to deal with C++11 well... – Sh4pe Aug 13 '13 at 15:17
  • 4
    You could also go GCC4.7+/MinGW – anthonyvd Aug 13 '13 at 15:18
  • Do you have experience how easy g++4.7 is to be installed and how well it performs? – Sh4pe Aug 13 '13 at 15:19
  • 3
    Also see the [VS Roadmap from Herb Sutter's talk at //build](http://channel9.msdn.com/Events/Build/2013/2-306), [roadmap from that talk](http://i.stack.imgur.com/tV8mt.png) (by [Casey](http://stackoverflow.com/a/18065102/420683)) – dyp Aug 13 '13 at 15:21
  • 1
    for me the reason to avoid VC++ for now is the slightly buggy variadic template and non static member initializer and using alias. Also clang compile speed seem to be order of magnitude faster than VC++. – yngccc Aug 13 '13 at 15:25
  • What about their standard library libc++? Don't you need it on Windows? Do you consider clang to be a production-ready compiler on Windows? – Sh4pe Aug 13 '13 at 15:26
  • You can use libstdc++ with Clang, but you need 4.6.3 and MinGW's linker, I believe. – Puppy Aug 13 '13 at 15:33
  • @Sh4pe DeadMG is right. See [my answer here](http://stackoverflow.com/questions/8882753/clang-on-windows). I still haven't got around to making GCC 4.8's libstdc++ work with Clang, nor getting libc++ in shape for distribution :-/. – rubenvb Aug 13 '13 at 15:52
  • @Sh4pe Don't expect to have that library play nice with the features VC++ says it "supports" anyways. See my updated answer. –  Aug 13 '13 at 15:57
  • @AnthonyVallée-Dubois and others suggesting g++/MinGW: please be advised that the GNU standard C++ library still does not support all C++11 features at the time of this writing (2014-03-20, g++ version 4.8.2), see http://gcc.gnu.org/projects/cxx0x.html . They finally got std::regex working but it is still not feature-complete. Let's hope the 4.9 release will reach full C++11 compliance. – András Aszódi Mar 20 '14 at 18:41

7 Answers7

43

I can only give you my experience as a developer, as I've been building against the cutting edge of C++ on Windows using Visual C++ for just about everything, while also installing several other compilers and IDEs (including building Clang myself on Windows for Visual Studio 2012, 2012 CTP, and 2013 Preview). The following is my experience up until right now (August 13th, 2013), and is based on Herb Sutter's talk and working with the compiler every day.

The Quick

Run in the opposite direction of Visual Studio / VC++. Support for C++11 is slow, and they're currently being crushed in terms of compiler features versus Clang and GCC.

The Present

Visual C++'s C++11 (and C++14 support) is beyond abysmal right now. They lack powerful features that make template metaprogramming in C++ great (using expressions in particular).

  • Using doesn't exist right now. I have spent hours and hours porting great C++11 code with using to VC++, only to have it break it certain places, snap, or just become near damn unmaintainable.

  • Variadic support in the CTP was horrifically terrible, and while it got better for Visual Studio 2013 Preview's version of the compiler, it's still fairly bad at complex variadic and template expressions that obey the standard (and compile fine in GCC and Clang).

  • =delete and =default are pretty much gone from VC++ right now; in the hopeful near future, maybe it will work out (and it should come "soon-ish", according to the roadmap) (I had to implement r-value constructors explicitly for many simple classes all the way down a 8-class inheritance hierarchy once. It was the worst slap in the face, when I watched GCC and Clang users get all of my explicit hardcoded work for free with =default).

  • As a holdover (primarily because of Windows OS code and some binary compatabilities), Empty-Base-Class-Optomizations in VC++ don't work. Don't expect your class hierarchy sizes or member layout to be optimized in the least (watch your ordering in std::tuple when packing variable types).

This is about all the frustrations I've come into contact with so far. They're work-aroundable -- I have to work with them every day -- but if you want great C++ support, you should jump for GCC or Clang and somehow make it work on your machine.

The Future

If you really want C++11, you will need to wait about a year, and even then Visual Studio 2013's release of VC++ will still be missing a few features (and don't expect them to be bugless either). VC++ for 2013 will also still be critically missing std::move and explicit r-value support in many places, making it painful when you expect things to work.

The Caveat

If you're not a powerful Vim user, you're low on options when it comes to IDEs that you can work with (that play nice with GDB/GCC or Clang).

  • QtCreator is nice, works with MinGW, and is generally fully featured enough to get work done.
  • Sublime Text can be used, but you'll have to write your own building system or delegate that to something else.
  • Code::Blocks's autocomplete is wonky and behaves strangely, and the IDE itself feels clunky.
  • Eclipse is supposed to be good, but my experiences with it are clunky and strange, with odd input lags at time (despite a 8.00 GB i7 Haswell machine using an SSD).
  • Visual Studio, as an IDE, is pretty solid. Then stack Visual Assist X on top, and it works pretty damn well for C++ coding. It's really the only reason I continue to stick with it, but I've already made headway into learning Vim so I can mostly ditch Visual Studio altogether, when the time comes.

About Libraries

Library support in VC++ is pretty complete (for as much as their broken compiler lets them be complete). It has regex, while most other libraries have non-existent or broken regex support. But that doesn't mean that the VC++ library plays nice with some C++11 features that it says it does (picture by melak47).

And Lastly

If you want code that you know is going to work in Windows, 100%, for the rest of eternity, you'll probably want to program against VC++. The other "benefit" is that the code you write in VC++ is the smallest subset of C++/C++11 you can write with, so in the end it should compile everywhere. Of course, that goes against the very idea of using beautiful C++11 and enjoying it, so... pick your poison(s) wisely.

Community
  • 1
  • 1
  • NetBeans and Eclipse have reasonable support for c++11 (tested with GCC) – Yankes Aug 13 '13 at 17:29
  • 1
    Excellent answer! Thank you very much! (And I consider myself a powerful vim user :) ) – Sh4pe Aug 13 '13 at 20:40
  • 2
    Please also note emacs as a full grown IDE for gcc/clang/gdb (especially gdb, auto-complete support comes with clang for emacs). Even for VS2012 development it can be better than Visual Studio IDE (using Makefile+cl.exe). – eci Aug 15 '13 at 14:12
  • I would say emacs, but I have 0 experience with it, and the OP made no mention of it (he has mentioned VIM, though). Your comment has been upvoted, though, so people see the goodness of emacs + makefile + cl.exe :D –  Aug 15 '13 at 17:15
11

VC's C++11 support is far from complete, but it does include the most important user-facing features.

And here's the other thing. In my experience, it is fine to install MinGW or Clang on Windows, but you're going to have some inconvenience because hardly anybody precompiles binaries for those compilers for Windows (whereas lots of people precompile binaries for Visual Studio).

In addition, there are as far as I am aware no environments for Windows which are remotely as advanced as Visual Studio for things like graphical debugging, intellisense, and stuff like that. When I tried Code::Blocks it just didn't work, realistically.

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • As I don't usually use IDEs (I use vim to edit my code, the shell to compile it and a command line debugger [gdb on OSX] to debug) that would not be a problem for me.... – Sh4pe Aug 13 '13 at 15:37
8

You can see here for a comprehensive comparison of compiler support for C++11 language features. Here's some info on VS's C++11/14 roadmap.

MSVC is lagging behind the other major C++ compilers but it's still got support for many of the most important features.

  • auto, lambdas, and rvalue references are available from VS10. IIRC there's a caveat with rvalue references that the compiler doesn't generate move construction and move assignment operators.

  • variadic templates and initializer lists are available in the VS2013 preview, including library support.

  • type aliasing (i.e., typedefs with the using keyword) is expected to be available in VS 2013 RTM.


If you don't need to interoperate with binaries generated by VS then installing another compiler such as GCC is workable. I understand Clang can also work in a mingw environment, with libstdc++ rather than libc++.

bames53
  • 86,085
  • 15
  • 179
  • 244
  • 1
    That's a nice comparison for C++11 language features. Do you know of a similar one for _library_ features? My understanding is that VS C++ library is almost 100% complete with respect to C++11, but the ones that come with other compilers, like gcc, still have copy-on-write strings and are missing important bits like . – Adrian McCarthy Aug 13 '13 at 15:40
  • @AdrianMcCarthy [This](http://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/) has a comparison of MSVC's library, libstdc++, and libc++. It doesn't get updated or contain details like whether `std::string` is still CoW, however. I think libstdc++'s `string` has been updated, though. – bames53 Aug 13 '13 at 15:54
  • @Adrian GCC's libstdc++ does not have COW strings, at least in C++11 mode. As far as I know, the library (as of MSVS2012) is feature complete except for stuff like `noexcept`, `constexpr` correctness, and other things related to missing language support. – rubenvb Aug 13 '13 at 15:54
  • I found this list of gcc's C++11 library compliance: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x It doesn't specifically address copy-on-write strings. I also found this comment which suggests it still does copy-on-write: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x – Adrian McCarthy Aug 13 '13 at 23:10
  • Sorry, the second link in my previous comment should have been: http://herbsutter.com/2013/05/13/gotw-2-solution-temporary-objects/#comment-10041 – Adrian McCarthy Aug 15 '13 at 13:03
5

http://nuwen.net/mingw.html

The nuwen distro is AWESOME! It is MinGW but it comes out much quicker than MinGW as new GCC releases come out. It also comes with all of boost and other useful libraries already compiled. It is all I use on windows anymore.

Jake
  • 747
  • 1
  • 5
  • 19
  • 1
    He recently released 4.8.1 but I haven't cheeked the concurrency stuff that was added into gcc 4.8.1 yet. GCC 4.8.1 is basically a C++11 compliant compiler sans any bugs and minor lack of support for something I think. – Jake Aug 13 '13 at 17:43
  • also, nuwen is 32-bit only, last time I checked. – TemplateRex Aug 13 '13 at 20:00
2

We are using C++11 for a few months already in production software across windows and linux in some here.com products without any problems. We use auto, lambdas, range for... Using Visual studio 2012 and gcc 4.7.

piotr
  • 5,657
  • 1
  • 35
  • 60
2

I have been using VS2012 and used C++11 features where possible. There are some bugs in the implementations and I have found it helpful to have another compiler to hand when I get errors from Visual Studio to compare against.

doctorlove
  • 18,872
  • 2
  • 46
  • 62
0

Clang and GCC to lead the way in terms of C++11 feature support and it appears to be a neck-and-neck race in terms of C++11 support between the two. MSVC is sadly panting trying to keep up and lagging behind. The Nuwen MingGW distro is, as Jake mentions, excellent and appears to be working well with Eclipse (Kepler release) and I didn't encounter too much pain using it with Netbeans 7.4 either. The Nuwen distro is currently at version 11.2 at the time of writing and, as you can see at Stephan's website, is now x64-native, featuring GCC 4.8.1 and Boost 1.54.0, with GCC's default mode also set to C++11.

I'm certainly beginning to use Eclipse Kepler and Nuwen MinGW in preference to MSVC 2012 more and more, but I'm largely a hobbyist C++ programmer still getting my feet wet and may not have hit the more obscure problems that those to whom C++ is their bread and butter may know about.

Darren Evans
  • 665
  • 10
  • 17