/O1, /O2 (Minimize Size, Maximize Speed)
This page is specific to:.NET Framework Version:1.12.03.03.54.0
Visual C++ Compiler Options
/O1, /O2 (Minimize Size, Maximize Speed)

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

/O1
/O2
Remarks

The following table describes /O1 and /O2.

Option

Equivalent to

Comment

/O1 (Minimize Size)

/Og /Os /Oy /Ob2 /Gs /GF /Gy

Creates the smallest code in the majority of cases.

/O2 (Maximize Speed)

/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy

Creates the fastest code in the majority of cases. (default setting for release builds)

/O1 and /O2 also enable the Named Return Value optimization, which eliminates the copy constructor and destructor of a stack based return value. Consider the following sample. The Test function will not create the copy constructor or destructor. Add output statements to the constructor, destructor and copy constructor to see the effect of the Named Return Value optimization when you run the program. For more information on Named Return Value Optimization in Visual C++, see http://go.microsoft.com/fwlink?linkid=55900.

// O1_O2_NRVO.cpp
// compile with: /O1
struct A {
   A() {}
   ~A() {}
   A(const A& aa) {}
};

A Test() {
   A a;
   return a;
}
int main() {
   A aa;
   aa = Test();
}

x86 Specific

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

END x86 Specific

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.

  2. Click the C/C++ folder.

  3. Click the Optimization property page.

  4. Modify the Optimization property.

To set this compiler option programmatically

See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View