Danra
Danra

Reputation: 9896

Visual Studio Compiler Default for /O

Does VS2010/12's compiler use a default optimization level when none of /Od,/O1,/O2,/Ox is provided in a C++ compilation command line?

I'm currently using /Od since I witnessed some optimization related bugs when using the other levels. However, this leads to /GS being disabled - which is unwanted.

When I clear the box for the "Project Properties->C/C++->Optimization->Optimization" option, I see the command line indeed doesn't contain any option. But I don't know if this just means the compiler uses some default optimization level.

Upvotes: 2

Views: 600

Answers (1)

Andrew Schofield
Andrew Schofield

Reputation: 56

No optimization seems to be the default - see output from "cl /?" below:

                          -OPTIMIZATION-

  /O1 minimize space                      /O2 maximize speed
  /Ob<n> inline expansion (default n=0)   /Od disable optimizations (default)
  /Og enable global optimization          /Oi[-] enable intrinsic functions
  /Os favor code space                    /Ot favor code speed
  /Ox maximum optimizations               /Oy[-] enable frame pointer omission

Upvotes: 4

Related Questions