[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Strategies for Smaller Code Size in C++

When using C++ where program size may be critical, there are certain strategies that a programmer can follow to ensure optimal code size.
NOTE
In all strategies, reducing the size of object may affect the performance of that code.
Some of these strategies are used by the proposed Embedded C++ (EC++) uses some of these strategies as part of its specification. Other strategies apply to C++ programming in general. All of these strategies may be used by any C++ program, whether the program follows the EC++ standard or not.
In CodeWarrior, you can group these into compiler-related, language-related, and library-related steps.
Compiler-related strategies
Compiler-related strategies rely on using compiler features to reduce the size of object code.
-
Size Optimizations-use the compiler size optimization settings
-
Inlining-how to control and limit the effectiveness of the
inline directive
Language-related strategies
Language-related strategies limit or avoid the use of ANSI/ISO C++ features. Although these features may make software design and maintenance easier, they often do so at the cost of affecting code size
-
Virtual Functions-not using virtual functions reduces the size of code
-
Runtime Type Identification-the compiler won't generate extra data if a program doesn't use Runtime Type Identification (RTTI)
-
Exception Handling-while CodeWarrior C++ provides zero-overhead exception handling to provide optimum execution speed, it still generates extra object code for exception support
-
Operator New-be careful not to throw an exception within the
new operator
-
Multiple Inheritance-the compiler won't generate extra data if the use of multiple inheritance isn't used
Library-related strategies
-
Stream-Based Classes-these classes in the Metrowerks Standard Libraries comprise a lot of object code
-
Alternative Class Libraries-non-standard class libraries may provide a subset of the standard library's functionality with less overhead
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 17, 2000