Portability of the C ++ Standard Library

I am working on large-scale, multi-platform, real-time applications. The projects I'm working on have no real use of containers or the standard library as a whole, no smart pointers or really any β€œmodern” features of the C ++ language. A large number of raw dynamically allocated arrays is a common place.

I would really like to start using the standard library and some of the C ++ 11 specifications, however there are many people who also work on my projects that contradict each other because "STL / C ++ 11 is not so portable, we risk using his". We run software on a wide variety of embedded systems, as well as full-fledged Ubuntu / Windows / Mac OS systems.

So to my question; What are the actual portability problems associated with the standard library and C ++ 11? Is this just a case where g ++ passed a specific version? Are there any platforms that do not have support? Are compiled libraries required, and if so, is it difficult to compile / compile them? Has anyone encountered serious issues burned by unbearable pure C ++?

+7
source share
5 answers

Library support for the new C ++ 11 standard is pretty simple for Visual C ++ 2012, gcc> = 4.7 and Clang> = 3.1, except for some concurrency. Another issue is compiler support for all functions of a single language. See Link for an up-to-date overview of supported C ++ 11 features.

For in-depth analysis of C ++ in an embedded / real-time environment, Scott Meyers presentation materials are the indefinite worst-case time that matters for real-time systems.

These are problems, not tolerance, that should be your main concern (if you care about your drum pacemaker ...)

+3
source

Any compiler for C ++ must support some version of the standard library. The standard library is part of C ++. Without supporting this, the compiler is not a C ++ compiler. I would be very surprised if any of the compilers that you are currently using do not support the C ++ 03 portable standard library, so there is no excuse. Of course, the compiler should be updated since 2003, but if you do not compile any archaic system that is supported only by the archaic compiler, you will not have problems.

As for C ++ 11, support is pretty good at the moment. Both GCC and MSVC already have most of the C ++ 11 standard library. Again, if you use the latest versions of these compilers and they support the systems for which you want to compile, then there is no reason why you cannot use a subset of the standard The C ++ 11 libraries they support are what almost all of this.

C ++ without a standard library is simply not C ++. Language and library functions go hand in hand.

There are lists of supported C ++ 11 library functions for GCC libstdC ++ and MSVC 2012 . I can't find anything like this for LLVM libC ++, but they have a clang C ++ 11 support page.

+3
source

The people you talk to confuse a few different questions. C ++ 11 is not portable today. I do not think that the compiler supports it 100% (although I may be wrong); you can avoid using large parts if (and only if) you restrict yourself to the latest compilers on two or three platforms (Windows and Linux, and probably Apple). Although these are the most visible platforms, they represent a small part of all machines. (If you're working on large-scale networking applications, Solaris is likely to be important, and Sun CC. If the Sun hadn't changed since the last time I worked on it, it means there are even parts of C ++ 03, which you cannot count on.)

STL is a completely different issue. This partly depends on what you mean by STL, but certainly there is no portability problem today when using std::vector . locale can be problematic for very few compilers (this was with Sun CC - with the Rogue Wave and Stlport library), and some of the algorithms, but, for the most part, you can almost everything in 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 really care about the presence of std::vector , wrap it in your own class. If this is not the case (it is unlikely if you do not return the car with time), just redefine it, exactly the same as in before standard days.

+2
source

Use STLPort with your existing compiler if it supports it . It is nothing more than a code library, and you use other libraries without problems, right?

0
source

Each permitted behavior defined by the implementation is provided in a publicly accessible standard design . There is nothing less portable in C + 11 than in C ++ 98.

0
source

All Articles