Take the 2-minute tour ×

I work on large scale, multi platform, real time networked applications. The projects I work on lack any real use of containers or the Standard Library in general, no smart pointers or really any "modern" C++ language features. Lots of raw dynamically allocated arrays are common place.

I would very much like to start using the Standard Library and some of the C++11 spec, however, there are many people also working on my projects that are against because "STL / C++11 isn't as portable, we take a risk using it". We do run software on a wide variety of embedded systems as well as fully fledged Ubuntu/Windows/Mac OS systems.

So, to my question; what are the actual issues of portability with concern to the Standard Library and C++11? Is it just a case of having g++ past a certain version? Are there some platforms that have no support? Are compiled libraries required and if so, are they difficult to obtain/compile? Has anyone had serious issues being burnt by non-portable pure C++?

share|improve this question
It is really down to the compilers available for the embedded platform. If your code has to run on some ancient 8-bit platform with a compiler written before standarization, then you could well run into portability issues. But if you have any vaguely recent G++ then you are pretty safe, at least WRT C++03. My experience is that it is just becoming too painful to support these old platforms, and "embedded" devices nowadays are pretty sophisticated computers. –  juanchopanza Jan 28 '13 at 20:50
Do you mean code portability or binary portability? –  Mooing Duck Jan 28 '13 at 21:03
Code portability –  oggmonster Jan 28 '13 at 21:05
The term "STL" refers to an old SGI library, which was so good it got integrated into the C++ standard library. C++11 added "move" functionality to containers, but nothing major, mostly some move-capable overloads and new ways to bypass copies using moves. C++11 allows implementation of more efficient containers. –  doug65536 Jan 28 '13 at 21:18

4 Answers 4

up vote 2 down vote accepted

Library support for the new C++11 Standard is pretty complete for either Visual C++ 2012, gcc >= 4.7 and Clang >= 3.1, apart from some concurrency stuff. Compiler support for all the individual language features is another matter. See this link for an up to date overview of supported C++11 features.

For an in-depth analysis of C++ in an embedded/real-time environment, Scott Meyers's presentation materials are really great. It discusses costs of virtual functions, exception handling and templates, and much more. In particular, you might want to look at his analysis of C++ features such as heap allocations, runtime type information and exceptions, which have indeterminate worst-case timing guarantees, which matter for real-time systems.

It's those kind of issues and not portability that should be your major concern (if you care about your granny's pacemaker...)

share|improve this answer
I think (and I'll admit that I'm basing my opinion mostly on hearsay) that most embedded systems use a compiler based on g++, clang or the EDF front end. In which case, they should have no problem with language features. The portability issues are more likely to arise on the larger machines&mdash;Sun CC (for Solaris) is quite behind the times, and I suspect the same is true of other truly proprietary compilers---I would certainly not use auto or lambdas if I thought I might have to port to a mainframe. –  James Kanze Jan 28 '13 at 21:58

Use STLPort with your existing compiler, if it supports it. This is no more than a library of code, and you use other libraries without problem, right?

share|improve this answer

The people you are talking to are confusing several different issues. C++11 isn't really portable today. I don't think any compiler supports it 100% (although I could be wrong); you can get away with using large parts of it if (and only if) you limit yourself to the most recent compilers on two or three platforms (Windows and Linux, and probably Apple). While these are the most visible platforms, they represent but a small part of all machines. (If you're working on large scale networked applications, Solaris will probably be important, and Sun CC. Unless Sun have greatly changed since I last worked on it, that means that there are even parts of C++03 that you can't count on.)

The STL is a completely different issue. It depends partially on what you mean by the STL, but there is certainly no portability problem today in using std::vector. locale might be problematic on a very few compilers (it was with Sun CC—with both the Rogue Wave and the Stlport libraries), and some of the algorithms, but for the most part, you can pretty much count on all of C++03.

And in the end, what are the alternatives? If you don't have std::vector, you end up implementing something pretty much like it. If you're really worried about the presence of std::vector, wrap it in your own class—if ever it's not available (highly unlikely, unless you go back with a time machine), just reimplement it, exactly like we did in the pre-standard days.

share|improve this answer

Any compiler for C++ should support some version of the standard library. The standard library is part of C++. Not supporting it means the compiler is not a C++ compiler. I would be very surprised if any of the compilers you're using at the moment don't portably support the C++03 standard library, so there's no excuse there. Of course, the compiler will have to be have been updated since 2003, but unless you're compiling for some archaic system that is only supported by an archaic compiler, you'll have no problems.

As for C++11, support is pretty good at the moment. Both GCC and MSVC have a large portion of the C++11 standard library supported already. Again, if you're using the latest versions of these compilers and they support the systems you want to compile for, then there's no reason you can't use the subset of the C++11 standard library that they support - which is almost all of it.

C++ without the standard library just isn't C++. The language and library features go hand in hand.

There are lists of supported C++11 library features for GCC's libstdc++ and MSVC 2012. I can't find anything similar for LLVM's libc++, but they do have a clang c++11 support page.

share|improve this answer
That VS C++0x status is way out of date. –  Puppy Jan 28 '13 at 21:35
@DeadMG Teaches me to not check my sources. –  Joseph Mansfield Jan 28 '13 at 21:48

Your Answer


