Compiler-related strategies rely on compiler features to reduce object code size.
Carbide compilers include optimization settings for size or speed and various levels of optimization. Choose size as your desired outcome and the level of optimization to apply.
Optimization settings for your target are controlled by settings in the Processor panel.
When debugging, compile your code without any optimizations. Some optimizations disrupt the relationship between the source and object code required by the debugger. Optimize your code after you have finished debugging.
See also C/C++ Language Panel.
With Carbide, you can disable inlining, allow normal inlining, auto-inline, or set the maximum depth of inlining.
Inlining can reduce or increase code size. There is no definite answer for this question. Inlining small functions can make a program smaller, especially if you have a class library with a lot of getter/setter member functions.
However, MSL C++ defines many functions as inline, which is not good if you want minimal code size. For optimal code size when using MSL C++, disable inlining when building the library. If you are not using MSL C++, normal inlining and a common-sense use of the keyword inline might improve your code size.
In Carbide, you control inlining as a language setting .
When debugging your code, disable inlining to maintain a clear correspondence between source and object code. After debugging, set the inlining level that has the best effect on your object code.
See also Inlining.