### Language-related Strategies

Language-related strategies limit or avoid the use of ISO C++ features. While these features can make software design and maintenance easier, they can also increase code size.

- Virtual Functions—Not using virtual functions reduces code size.
- Runtime Type Identification—Extra data is not generated if program does not use Runtime Type Identification (RTTI).
- Exception Handling—While the Carbide.c++ compiler provides zero-overhead exception handling to provide optimum execution speed, it still generates extra object code for exception support.
- Operator New—Do not throw an exception within the new operator.
- Multiple and Virtual Inheritance

#### Virtual Functions

For optimal code size, do not use virtual functions unless absolutely necessary. A virtual function is never dead-stripped, even if it is never called.

#### Runtime Type Identification

If code size is an issue, do not use RTTI because it generates a data table for every class. Disabling RTTI decreases the size of the data section.

The EC++ proposal does not allow runtime type identification.

See also “Controlling RTTI”.

#### Exception Handling

If you must handle exceptions, be careful when using C++ exception handling routines. Carbide has a zero runtime overhead error handling mechanism. However, using exceptions does increase code size, particularly the exception tables data.

The EC++ proposal does not allow exception handling.

NOTE The proposed ISO standard libraries and the use of the new operator require exception handling.

#### Operator New

The C++ new operator might throw an exception, depending on how the runtime library implements the new operator. To make the new operator throw exceptions, set __throws_bad_alloc to 1 in the prefix file for your target and rebuild your library. To prevent the new operator from throwing exceptions, set __throws_bad_alloc to 0 in the prefix file for your target and rebuild your library.

See your release notes or Targeting manual for more information.

#### Multiple and Virtual Inheritance

Implementing multiple inheritance requires a modest amount of code and data overhead. The EC++ proposal does not allow multiple inheritance.

For optimal code size, do not use virtual inheritance. Virtual base classes are often complex and add a lot of code to the constructor and destructor functions.

The EC++ proposal does not allow virtual inheritance.