Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
Compiler Options
 /O1, /O2 (Minimize Size, Maximize S...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
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

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker