Table of Contents
Fetching ...

Transforming C++11 Code to C++03 to Support Legacy Compilation Environments

Gábor Antal, Dávid Havas, István Siket, Árpád Beszédes, Rudolf Ferenc, József Mihalicza

TL;DR

The paper tackles enabling legacy C++03 environments to compile code written with C++11 features by introducing an automated source-to-source backporting framework built on clang. It describes a two-part system: a transformation engine that rewrites modern constructs into their C++03 equivalents, and an incremental workflow backed by a SQLite database to minimize work between builds, plus traceability between original and transformed code. The authors catalog specific transformations (e.g., in-class member initialization, auto deduction, lambdas, range-based for loops, constructor delegation, and type aliases) with explicit limitations, and validate the approach through functional and performance testing on industrial and open-source codebases. The results indicate practical usefulness, open-source availability, and clear integration pathways into diverse development and CI processes, while acknowledging current limitations and future improvements. Overall, the framework enables developers to leverage modern C++ features during development without sacrificing compatibility with legacy compilation environments.

Abstract

Newer technologies - programming languages, environments, libraries - change very rapidly. However, various internal and external constraints often prevent projects from quickly adopting to these changes. Customers may require specific platform compatibility from a software vendor, for example. In this work, we deal with such an issue in the context of the C++ programming language. Our industrial partner is required to use SDKs that support only older C++ language editions. They, however, would like to allow their developers to use the newest language constructs in their code. To address this problem, we created a source code transformation framework to automatically backport source code written according to the C++11 standard to its functionally equivalent C++03 variant. With our framework developers are free to exploit the latest language features, while production code is still built by using a restricted set of available language constructs. This paper reports on the technical details of the transformation engine, and our experiences in applying it on two large industrial code bases and four open-source systems. Our solution is freely available and open-source.

Transforming C++11 Code to C++03 to Support Legacy Compilation Environments

TL;DR

The paper tackles enabling legacy C++03 environments to compile code written with C++11 features by introducing an automated source-to-source backporting framework built on clang. It describes a two-part system: a transformation engine that rewrites modern constructs into their C++03 equivalents, and an incremental workflow backed by a SQLite database to minimize work between builds, plus traceability between original and transformed code. The authors catalog specific transformations (e.g., in-class member initialization, auto deduction, lambdas, range-based for loops, constructor delegation, and type aliases) with explicit limitations, and validate the approach through functional and performance testing on industrial and open-source codebases. The results indicate practical usefulness, open-source availability, and clear integration pathways into diverse development and CI processes, while acknowledging current limitations and future improvements. Overall, the framework enables developers to leverage modern C++ features during development without sacrificing compatibility with legacy compilation environments.

Abstract

Newer technologies - programming languages, environments, libraries - change very rapidly. However, various internal and external constraints often prevent projects from quickly adopting to these changes. Customers may require specific platform compatibility from a software vendor, for example. In this work, we deal with such an issue in the context of the C++ programming language. Our industrial partner is required to use SDKs that support only older C++ language editions. They, however, would like to allow their developers to use the newest language constructs in their code. To address this problem, we created a source code transformation framework to automatically backport source code written according to the C++11 standard to its functionally equivalent C++03 variant. With our framework developers are free to exploit the latest language features, while production code is still built by using a restricted set of available language constructs. This paper reports on the technical details of the transformation engine, and our experiences in applying it on two large industrial code bases and four open-source systems. Our solution is freely available and open-source.
Paper Structure (24 sections, 13 figures, 4 tables)

This paper contains 24 sections, 13 figures, 4 tables.

Figures (13)

  • Figure 1: General use case of the framework
  • Figure 2: Content of a compile_commands.json file
  • Figure 3: Flow chart of the transformation framework
  • Figure 4: In-class member initialization examples
  • Figure 5: Auto type deduction examples
  • ...and 8 more figures