Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 2.77 KB

o1-o2-minimize-size-maximize-speed.md

File metadata and controls

50 lines (34 loc) · 2.77 KB
title description ms.date f1_keywords helpviewer_keywords ms.assetid
/O1, /O2 (Minimize Size, Maximize Speed)
The MSVC compiler options /O1 and /O2 specify all optimizations for minimum size or maximum speed.
07/08/2020
/O2
/O1
maximize speed compiler option [C++]
minimize size compiler option [C++]
-O2 compiler option [C++]
fast code
small code
O2 compiler option [C++]
/O2 compiler option [C++]
-O1 compiler option [C++]
O1 compiler option [C++]
/O1 compiler option [C++]
2d1423f5-53d9-44da-8908-b33a351656c2

/O1, /O2 (Minimize Size, Maximize Speed)

Selects a predefined set of options that affect the size and speed of generated code.

Syntax

/O1
/O2

Remarks

The /O1 and /O2 compiler options are a quick way to set several specific optimization options at once. The /O1 option sets the individual optimization options that create the smallest code in the majority of cases. The /O2 option sets the options that create the fastest code in the majority of cases. The /O2 option is the default for release builds. This table shows the specific options that are set by /O1 and /O2:

Option Equivalent to
/O1 (Minimize Size) /Og /Os /Oy /Ob2 /GF /Gy
/O2 (Maximize Speed) /Og /Oi /Ot /Oy /Ob2 /GF /Gy

/O1 and /O2 are mutually exclusive.

Note

x86-specific
These options imply the use of the Frame-Pointer Omission (/Oy) option.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

  2. Select the Configuration Properties > C/C++ > Optimization property page.

  3. Modify the Optimization property.

To set this compiler option programmatically

  • See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.Optimization%2A.

See also

/O options (Optimize code)
MSVC compiler options
MSVC compiler command-line syntax
/EH (Exception handling model)