The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

/Ob (Inline Function Expansion)


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at -Ob (Inline Function Expansion).

Controls inline expansion of functions.


Disables inline expansions. By default, expansion occurs at the compiler's discretion on all functions, often referred to as auto-inlining.

Allows expansion only of functions marked inline, __inline, or __forceinline, or in a C++ member function defined in a class declaration.

The default value. Allows expansion of functions marked as inline, __inline, or __forceinline, and any other function that the compiler chooses.

/Ob2 is in effect when /O1, /O2 (Minimize Size, Maximize Speed) or /Ox (Full Optimization) is used.

This option requires that you enable optimizations using /O1, /O2, /Ox, or /Og.

The compiler treats the inline expansion options and keywords as suggestions. There is no guarantee that any function will be expanded inline. You can disable inline expansions, but you cannot force the compiler to inline a particular function, even when using the __forceinline keyword.

You can use the #pragmaauto_inline directive to exclude functions from consideration as candidates for inline expansion. Also see the #pragmaintrinsic directive.

System_CAPS_ICON_note.jpg Note

Information that is gathered from profiling test runs overrides optimizations that would otherwise be in effect if you specify /Ob, /Os, or /Ot. For more information, see Profile-Guided Optimizations.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Working with Project Properties.

  2. Expand Configuration Properties, C/C++, and select Optimization.

  3. Modify the Inline Function Expansion property.

To set this compiler option programmatically

/O Options (Optimize Code)
Compiler Options
Setting Compiler Options