Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
C/C++ Languages
Pragma Directives
 optimize

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

Other versions are also available for the following:
C/C++ Preprocessor Reference
optimize

Specifies optimizations to be performed on a function-by-function basis.

#pragma optimize( "[optimization-list]", {on | off} )

The optimize pragma must appear outside a function and takes effect at the first function defined after the pragma is seen. The on and off arguments turn options specified in the optimization-list on or off.

The optimization-list can be zero or more of the parameters shown in the following table.

Parameters of the optimize Pragma
Parameter(s) Type of optimization

g

Enable global optimizations.

p

Improve floating-point consistency.

s or t

Specify short or fast sequences of machine code.

y

Generate frame pointers on the program stack.

These are the same letters used with the /O compiler options. For example:

#pragma optimize( "tp", on )

Using the optimize pragma with the empty string ("") is a special form of the directive:

When you use the off parameter, it turns the optimizations, listed in the table above, off.

When you use the on parameter, it resets the optimizations to those that you specified with the /O compiler option.

#pragma optimize( "", off )
.
.
.
#pragma optimize( "", on ) 
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