OME Files C++ and C++1105 Dec 2016
We have been evaluating the switch from C++98 to C++11 for over 18 months. Up until now, we have remained using C++98 in order to continue to support older systems with compilers which do not support C++11. However, circumstances have recently changed which will necessitate a switch at some point in the near future.
Most current platforms support C++11 and C++14, with some exceptions (workarounds are noted)
|CentOS 6||GCC 4.6||Unsupported by default*||Unsupported by default*|
|CentOS 7||GCC 4.8||Mostly supported||Partially supported|
|FreeBSD 10||Clang/LLVM 3.4||Fully supported||Fully supported|
|FreeBSD 11||Clang/LLVM 3.8||Fully supported||Fully supported|
|MacOS X 10.10||Apple LLVM 7.3||Fully supported||Fully supported|
|MacOS X 10.11||Apple LLVM 8.0||Fully supported||Fully supported|
|MacOS X 10.12||Apple LLVM 8.0||Fully supported||Fully supported|
|Ubuntu 14.04||GCC 4.8||Mostly supported||Partially supported|
|Ubuntu 16.04||GCC 5.3||Fully supported||Fully supported†|
|Visual Studio 2013||VC12‡||Partially supported||Mostly unsupported|
|Visual Studio 2015||VC13‡||Supported||Partially supported|
|Visual Studio 2017||VC15‡||Supported||Supported|
† Boost 1.58 provided by this release does not build OME Files with C++14, but does build with C++11; see trac ticket
‡ Microsoft Visual C++ lags significantly behind GCC and Clang/LLVM, but VS2013 contains a useful subset of features, which are improved upon significantly with VS2015 and later
The support classifications above are broad; please see the following references for full feature coverage:
All of our third-party dependencies have supported building with a C++11 or C++14 compiler for some time. However, more recently some of our dependencies have begun to require it, or will require it in their next major release.
- Qt 5.7 (released June 2016) requires C++11
- ICU 59 (expected April 2017) is expected to require C++11 (delayed from ICU 58 to 59)
For many users, these libraries are provided by package repositories, including Linux distributions’ package managers, MacOS X homebrew and FreeBSD ports. As these package repositories begin to provide the updated C++11 versions of these libraries, OME Files C++ will no longer build with them. While some of these C++11 libraries are optional (Qt5), others such as ICU are required by Boost and Xerces-C++ for full Unicode support, which is needed by the OME-XML data model. As a result, C++11 support will become a necessity for continued use of these libraries as the versions requiring C++11 enter mainstream use.
The benefits of C++11
C++11 adds a number of useful features to the language, including:
- delegating constructors
- initialiser lists
- rvalue references
- variadic templates
and library features, including:
These features are all supported by the compilers on the above platforms. Some additional features (not included here) are not yet supported by the compilers on every platform, and so can’t yet be used.
These features benefit the project in several ways:
- they reduce the code size dramatically by permitting much more concise code with reduced boilerplate (by around 50% in one test conversion of a single component)
- they allow the use of standard library features in place of Boost
equivalents, which aids interoperability (e.g.
std::shared_ptrin place of
- they allow improved performance of standard library containers
through the use of rvalue references, and also allow the use of new
features such as
boost::shared_ptrin certain situations, again improving performance
- they make the library easier to use, for example the use of
initialiser lists can reduce the
PixelBuffernD array addressing from multiple lines to a single line of code
- they make the library more understandable and more familiar for
users already using these features with other libraries; in
particular features such as
std::shared_ptrhave been available since VS2010 for Windows developers and their use is already widespread
- all of our supported platforms can support a sizeable subset of C++11
- our dependencies will increasingly require C++11
- there are significant benefits to switching to C++11 as a result of the features and performance gains it brings
we plan to make a C++11 compiler a requirement in our upcoming 0.3.0 release of OME Files C++, and begin using a subset of the C++11 features available across our supported platforms. For most users, the transition should be entirely transparent and will require no immediate code changes as we will leave compatibility typedefs in place through a transitional period.
If this will present any problems, please get in touch through our mailing lists or forums so that we can discuss any concerns you may have. Likewise, if the change is something which you will find useful and beneficial, we would also like to hear from you.