8.41 --cpp_compat

Compiles C++ code to maximize binary compatibility.

Usage

Use --cpp11 --cpp_compat to compile C++11 source code using a subset of features that maximizes compatibility with source code compiled with C++03.

Use --cpp --cpp_compat to compile C++03 source code maximizing binary compatibility with C++03 code compiled using older compiler versions.

The --cpp11 --cpp_compat options behave in the same way as --cpp11 with the following restrictions:

  • When the --exceptions option is selected, the array new operator with a length not known at compile time does not perform bounds checking. This means that std::bad_alloc is thrown if there is an error rather than std::bad_array_new_length.
  • When the --exceptions option is selected, the delegating constructors language feature is disabled. Any use of delegating constructors when the --cpp_compat is selected results in an error message.

armcc passes the --cpp_compat option to armlink if it invokes armlink to perform a final link step.

You can combine the --cpp_compat option with other source language command-line options. For example:

  • armcc --cpp_compat --cpp11
  • armcc --cpp_compat --cpp
  • armcc --cpp_compat --cpp --gnu

Examples

When compiling with --cpp11 --exceptions, code can catch std::bad_array_new_length:

void variable_length_array_new(unsigned i) {
    bool exception_thrown = false;
    try {
        new int[i + 0x40000000];
    } catch (std::bad_array_new_length e)
}

When compiling with --cpp11 --cpp_compat --exceptions, code can only catch std::bad_alloc:

void variable_length_array_new_cpp_compat(unsigned i) {
    bool exception_thrown = false;
    try {
        new int[i + 0x40000000];
    } catch (std::bad_alloc e)
}

Default

By default, the --cpp_compat option is not enabled.

For files with a suffix of .cpp, .cxx, .c++, .cc, or .CC, the --cpp option applies by default.

Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.