10 ms·
C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel
- nicholassmith 14y agoGCC guys have been on a tear getting the support built in, but it's nice to see Microsoft is slowly catching up as well.
- qompiler 14y ago> I’m also going to omit Intel’s library from this comparison. Without a reason?
- xyzzy123 14y agoWith icc you usually use libstdc++ (mac/linux) or the MSVC C++ libraries (windows).
- Keyframe 14y agoShame about C99 support. I'm afraid to even ask about C11.
- fafner 14y agoI wonder why there is no c11status page for GCC. They already added support for many things to GCC 4.6/4.7. http://gcc.gnu.org/gcc-4.7/changes.html http://gcc.gnu.org/gcc-4.7/changes.html > There is support for some more features from the C11 revision of the ISO C standard. GCC now accepts the options -std=c11 and -std=gnu11, in addition to the previous -std=c1x and -std=gnu1x. > * Unicode strings (previously supported only with options such as -std=gnu11, now supported with -std=c11), and the predefined macros __STDC_UTF_16__ and __STDC_UTF_32__. > * Nonreturning functions (_Noreturn and <stdnoreturn.h>). > * Alignment support (_Alignas, _Alignof, max_align_t, <stdalign.h>). > * A built-in function __builtin_complex is provided to support C library implementation of the CMPLX family of macros. http://gcc.gnu.org/gcc-4.6/changes.html http://gcc.gnu.org/gcc-4.6/changes.html > There is now experimental support for some features from the upcoming C1X revision of the ISO C standard. This support may be selected with -std=c1x, or -std=gnu1x for C1X with GNU extensions. Note that this support is experimental and may change incompatibly in future releases for consistency with changes to the C1X standard draft. The following features are newly supported as described in the N1539 draft of C1X (with changes agreed at the March 2011 WG14 meeting); some other features were already supported with no compiler changes being needed, or have some support but not in full accord with N1539 (as amended). > * Static assertions (_Static_assert keyword) > * Typedef redefinition > * New macros in <float.h> > * Anonymous structures and unions and glibc added support http://sourceware.org/ml/libc-alpha/2012-06/msg00807.html http://sourceware.org/ml/libc-alpha/2012-06/msg00807.html > * ISO C11 support: > > + define static_assert > > + do not declare gets > > + declare at_quick_exit and quick_exit also for ISO C11 > > + aligned_alloc. NB: The code is deliberately allows the size parameter > to not be a multiple of the alignment. This is a moronic requirement > in the standard but it is only a requirement on the caller, not the > implementation. > > + timespec_get added > > + uchar.h support added > > + CMPLX, CMPLXF, CMPLXL added > > Implemented by Ulrich Drepper. But I don't know what's still missing and I doubt that glibc will implement the range check library (Annex K).
- micampe 14y agoThe table is inaccurate on that: GCC is listed as full support, but it doesn't implement at least the same feature clang is missing (floating point pragmas), which is the only C99 missing feature in clang, as far as I know, so I don't understand the difference.
- pjmlp 14y agoC99 is probably going to be the last C standard most commercial compiler vendors will care about. On the desktop and server the world is moving from C to C++/Objective-C, with C still being very important in the embedded space. Microsoft's official position is C++ is the future and C is legacy on Windows platforms. Even the two most important open source C and C++ compilers are now both written in C++, although given their open source nature, I expect they to keep on supporting C contrary to the commercial vendors.
- ori_b 14y agoC11 language support seems to be complete since GCC 4.7.
- pjmlp 14y agoMy main point was about commercial compiler vendors.
- ori_b 14y agoIntel's C compiler also claims to support most of C11, as, apparently, does Clang. That covers the popular Unix compilers. Microsoft seems to be the big outlier, but they don't even care about C99. I admit, though, I have no idea what commercial compilers are popular in the Windows world. I am under the impression that you either used Intel's compiler, Microsoft's compiler, or a free port of the Unix toolchain, but I don't really do Windows development.
- pjmlp 14y agoYou left out all the big commercial UNIX vendors, embedded market, real time operating systems, HPC and game development.
- ori_b 14y agoHPC is usually one of IBM XLC, Intel ICC, or GCC. All of them support most or all of the C11 language features. For commercial unixes, it's hard to find documentation on C versions supported by Oracle Solaris Studio, but it was last released in 2011. HPUX ACC was last released in 2010, so I would be very surprised if it supported the 2011 C standard already. That doesn't meant it won't, but it does mean that it moves slowly. Not surprising, since large unix vendors operate in a market where stability is valued above most other things. IBM XLC already supports C11. The embedded market tends to use GCC, from what I can tell, although it may vary widely by company. ArmCC is around, but the last major looks like it was in 2011 (minor updates since). I don't know what future versions will bring, but I'd be surprised if they don't at least end up supporting the memory model and atomics. These are /useful/ when writing embedded code. RTOS development is pretty much the same situation as embedded. From what I understand, game development usually isn't done in C, but I'd be very curious to know how the compilers there differ from compilers used for normal desktop applications. Which ones are normally used for game development? EDIT: And, apparently, Microsoft is going to be adding some C11 features to C, as well as most of C99, because it will be piggybacking off the C++11 updates. So even the company that said it was ignoring anything newer than C90 is adding C11 features. That was a surprise to me. Perhaps you could list some widely used compilers that have said they will not be moving towards C11 support?
- fafner 14y agoI wonder why libstdc++ development is so slow. Regex support has been missing since TR1.
- alecthomas 14y agoI can't be sure, but the fact that libstdc++ is ABI incompatible with the current stdlib probably doesn't help adoption and thus usage and testing. If you want to use libstdc++ every dependency must also be compiled against it, including any system packages.
- plorkyeran 14y agolibstdc++ != libc++ libstdc++ is gcc's C++ stdlib; libc++ is clang's (although clang can used libstdc++). libc++ supports all of C++11, although there's still some bugs. libc++ is ABI incompatible with libstdc++, but it's explicitly designed to support using both libstdc++ and libc++ within the same program, so that's often not a program.
- alecthomas 14y agoSorry, rereading my post I realise I omitted some text (I was on my phone), and shouldn't have said "ABI incompatible". What I meant to say was that the C++11 versions of both libstdc++ [1] and libc++ [2] are effectively incompatible with the C++98 version of libstdc++. The main point still stands: you effectively can not link against libraries using different versions of the C++ standard unless you're very lucky. [1] http://gcc.gnu.org/wiki/Cxx11AbiCompatibility http://gcc.gnu.org/wiki/Cxx11AbiCompatibility [2] http://stackoverflow.com/questions/12542971/using-libstdc-compiled-libraries-with-clang-stdlib-libc http://stackoverflow.com/questions/12542971/using-libstdc-co...
- delinka 14y agoA bit off-topic, but since I discovered Intel's compiler years ago, I've been wondering why I, the generic desktop programmer, would want to pay for a compiler when the free ones are pretty damn good. I can think of only a small set of use cases where the CPU manufacturer might know the best optimization for some code that's heavily utilized in compute-intensive projects, but that seems like a small market.
- duaneb 14y agoSupport? That's a big thing for some people.
- deleted 14y ago[deleted]
- fafner 14y agoIt's been ages since I used icc. But last time I used it, it could really do magic when it came to vectorisation and SSE support. So if you have heavy numeric code then it might be worth it. For Linux you can get a free (as in beer) edition for non-commercial use. For normal desktop applications it probably doesn't make sense.
- octo_t 14y agoICC is (in terms of basically all optimisations) leagues ahead of the open-source compilers. The vectorised code the compiler produces is also a lot better. See http://stackoverflow.com/a/11227902/1346405 http://stackoverflow.com/a/11227902/1346405
- agentultra 14y agoC++11 rocks and I think Bjarne was right in saying that it feels like a new language. This isn't your grand-daddy's C++. It's certainly worth considering for your next project and valuable to learn if only to make you a better programmer.
- xyzzy123 14y agoEven if it doesn't make you a better programmer, "auto" will cut down on RSI ;) I hate typing iterator type names.
- pjmlp 14y agoStill way better than Objective-C method calls though.
- coldtea 14y agoNot really. For one, everybody does it them with XCode and auto-complete. Second, the verboseness there plays a function: it makes them self-documenting, whereas with C++ types/iterators/etc you're just repeating yourself.
- pjmlp 14y agoI used Objective-C in the NeXT days...
- coldtea 14y agoHah. Nice. At least you didn't have to write UI code for it!
- pjmlp 14y agoIt was a bit sad actually. We were porting a particle simulation framework done in Objective-C with Renderman shaders to C++/Windows, because we thought NeXT would die soon. This was way before Apple decided to buy NeXT.
- alecthomas 14y agoI recently wrote an entity-component framework [1] for C++ using a bunch of C++11 and it was really quite enjoyable. At the time, VC++ didn't support variadic templates which was a bummer, but they've since released a feature pack with it. It's great to see adoption coming along so quickly. [1] https://github.com/alecthomas/entityx https://github.com/alecthomas/entityx
- scott_s 14y agoWhat new parts of C++ did you appreciate the most?
- ajross 14y agoNot the OP, but I'm going to put my vote down for a simple and comparatively less discussed feature: initializer lists. Declarative programming is a huge win, and being able to declare objects just like you do "static data" is a huge readability win. Other stuff is mostly about fixing bugs in the standard (<cough> rvalue references </cough>), cleaning up the syntax (auto) or providing new syntax for useful but comparatively rare operations (lambdas). That's all good, but initializer lists can change the paradigm of how the code is presented, and that's better.
- pmelendez 14y ago"useful but comparatively rare operations (lambdas)" I think it is rare just because people is not used to it, once they discover the flexibility of lambdas functions you would start seeing them more often (even abuse of them) I am remaking a event system that I did for a turn based card game and the use of lambdas is just so natural that I realized now how painful and weak was the previous code.
- ajross 14y agoLambda functions are just syntax, they aren't "flexible" in any meaningful way I can see. And I argue that they certainly are rare -- virtually all major languages (other than C and C++03) have some form of straightforward anonymous function with some form of local scope closure (and to be clear: C++11's implementation of that bit is sort of a mess!). Other than node.js, virtually none of them make regular use of them. When they do, it's mostly just to have a convenient way of passing a callback. Lambda's are good. But as implemented in C++11 they really don't do anything to change the nature of the code being written. On the other hand, proper use of initializers does, by virtue of not having to write a thousand setXXX() functions, etc...
- msvan 14y agoWhy is it that Microsoft seems to lag so far behind? Don't they have lots of funds and competent programmers to take the lead? Or is it simply not a priority?
- stuffandthings 14y agoOn the MSVC blog, there's a post announcing C++11 support in VS2012. The comments, of course, are filled with angry devs posting about what a joke the initial VS2012 support is. Buried in those comments is one from a MS dev who claims that he is the only guy working on the standard library implementation. Kinda sad, really.
- danieldk 14y agoBuried in those comments is one from a MS dev who claims that he is the only guy working on the standard library implementation. Doesn't Microsoft license its standard library from Dinkumware? http://dinkumware.com/ http://dinkumware.com/
- shmerl 14y agoWhen exactly did Microsoft not lag behind in anything?
- cjensen 14y agoMicrosoft always does well when it is killing some competition. Ever since Borland and Watcom died, Microsoft has been stagnant in development. They really need to fix that. It's not enough to just chant "Developers!" while running around a stage. You actually have to help them.
- agwa 14y ago> It looks like GCC is overtaking Clang as the compiler with the best C++11 support There seems to be a myth going around that Clang has or had better C++11 support. Apparently when the author did his last shootout Clang had a slight edge over GCC, but over the long run GCC has had the better support most of the time. I started using C++11 (or C++0x as it was still called) in February 2011 and at that time GCC 4.5 had significantly better support than Clang. Not to denigrate Clang's other qualities - I wanted Clang's better error messages but had to stick with GCC to get the C++0x support I needed.
- dschulz 14y agos/Yes/✔/g s/No/✘/g s/Partial/∂/g s/Don't know/?/g
- known 14y agoHope they'd not break http://en.wikipedia.org/wiki/Standard_Template_Library http://en.wikipedia.org/wiki/Standard_Template_Library and http://en.wikipedia.org/wiki/Boost_%28C%2B%2B_libraries%29 http://en.wikipedia.org/wiki/Boost_%28C%2B%2B_libraries%29 based applications