-O
Syntax
-O[n|l|m|h|hs|hz]
Parameters
| None* (Best debug support) |
| Low* |
| Medium |
| High, balanced |
| High, favoring speed |
| High, favoring size |
*All optimizations performed at level Low will be performed also at None. The only difference is that at level None, all non-static variables will live during their entire scope.
Description
Use this option to set the optimization level to be used by the compiler when optimizing the code. If no optimization option is specified, the optimization level Low is used by default. If only -O is used without any parameter, the optimization level High balanced is used.
A low level of optimization makes it relatively easy to follow the program flow in the debugger, and, conversely, a high level of optimization makes it relatively hard.
At high optimization levels, when favoring speed or size (-Ohs or -Ohz), the compiler will emit AEABI attributes indicating the requested optimization goal. This information can be used by the linker to select smaller or faster variants of DLIB library functions.
If a module referencing a function is compiled with
-Ohs, and the DLIB library contains a fast variant, that variant is used.If all modules referencing a function are compiled with
-Ohz, and the DLIB library contains a small variant, that variant is used.
For example, using -Ohz for Cortex-M0 will result in the use of a smaller AEABI library routine for integer division.
See also
Controlling compiler optimizations.
Caution
Project>Options>C/C++ Compiler>Optimizations