How to migrate codebase to C++11

Jonathan Wakely jwakely.gcc@gmail.com
Mon Aug 22 13:31:00 GMT 2016


On 22 August 2016 at 14:15, Tamás Kiss wrote:
> Hi,
>
> I'd like to ask some questions about codebase migration to C++11. In
> the company I work, we have a large C++ codebase, currently C++98. We
> recently upgraded GCC to 4.8.3, so at last using C++11 became a
> possibility. Our product is built on-, and runs on x86_64 Linux
> platform only, so no cross-platform considerations are needed. We also
> make use of some third party C++ libraries, that are also C++98. We
> build everything from sources (including the 3PPs), so recompilation
> is not an issue, and we always deploy all of our built code together
> (i.e. no partial upgrades), so backwards compatibility between our
> components is also not a problem.
>
> We plan to recompile our own codebase with the -std=c++11 flag, and if
> there are any problems, we can rewrite the necessary code parts. And
> here comes my question at last :) Do we need to use the -std=c++11
> flag also while recompiling the 3PP libraries, or is it enough to use
> the same build environment with the same GCC version as used for our
> own code? Or more simply put: can we use C++11 code and C++98
> libraries together, given that they are compiled with the same
> compiler on the same environment, just with different language version
> flags?

Yes.

There are some rare corner cases that can cause problems, see
https://gcc.gnu.org/wiki/Cxx11AbiCompatibility

With GCC 4.8.3 you should be OK.

Be aware that the ABI for the new C++11 components was not stable
until GCC 5.1, so if you upgrade to GCC 4.9.x you'll need to rebuild
everything again, and similarly if you upgrade to GCC 5.x

Since GCC 5.1 the C++11 support is stable and provides the same level
of ABI compatibility between releases as has long been available for
C++98 support.

See https://gcc.gnu.org/gcc-6/porting_to.html for some common problems
encountered when switching to C++11.



More information about the Gcc-help mailing list