/Ox
(Enable Most Speed Optimizations)
The /Ox
compiler option enables a combination of optimizations that favor speed. In some versions of the Visual Studio IDE and the compiler help message, it's called full optimization, but the /Ox
compiler option enables only a subset of the speed optimization options enabled by /O2
.
Syntax
/Ox
Remarks
The /Ox
compiler option enables the /O
compiler options that favor speed. The /Ox
compiler option doesn't include the additional /GF
(Eliminate Duplicate Strings) and /Gy
(Enable Function-Level Linking) options enabled by /O1
or /O2
(Minimize Size, Maximize Speed). The additional options applied by /O1
and /O2
can cause pointers to strings or to functions to share a target address, which can affect debugging and strict language conformance. The /Ox
option is an easy way to enable most optimizations without including /GF
and /Gy
. For more information, see the descriptions of the /GF
and /Gy
options.
The /Ox
compiler option is the same as using the following options in combination:
/Ob
(Inline Function Expansion), where the option parameter is 2 (/Ob2
)
/Ox
is mutually exclusive from:
You can cancel the bias toward speed of the /Ox
compiler option if you specify /Oxs
, which combines the /Ox
compiler option with /Os
(Favor Small Code). The combined options favor smaller code size. The /Oxs
option is exactly the same as specifying /Ox
/Os
when the options appear in that order.
To apply all available file-level optimizations for release builds, we recommend you specify /O2
(Maximize Speed) instead of /Ox
, and /O1
(Minimize Size) instead of /Oxs
. For even more optimization in release builds, also consider the /GL
(Whole Program Optimization) compiler option and /LTCG
(Link-time Code Generation) linker option.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Optimization property page.
Modify the Optimization property.
To set this compiler option programmatically
- See Optimization.
See also
/O
Options (Optimize Code)
MSVC Compiler Options
MSVC Compiler Command-Line Syntax