Inlining Function Calls (/Ob0, /Ob1, and /Ob2)

Inlining is similar to the use of intrinsic functions, except that it is not restricted to a specific set of library functions. Inlining allows the compiler to insert a copy of a function in each place it is called. This removes the overhead of calling a function (described in the previous section), but having multiple copies of a function can make your program larger.

You can explicitly mark a function as a candidate for inlining by declaring it with the __inline keyword, or in C++, the inline keyword. Any C++ member functions that are defined within the class declaration are implicitly considered inline functions.

Inlining is performed at the discretion of the compiler. If a function more than a few lines long is declared as an inline function, the compiler ignores the __inline keyword. The /Obn option controls the degree to which the compiler performs inlining.

The /Ob0 option disables all inlining, even for functions explicitly declared as inline functions. This is the default when /Od is specified.

The /Ob1 option expands all functions declared as inline, at the compiler's discretion. This is the default when /Od is not specified.

The /Ob2 option expands all functions declared as inline, at the compiler's discretion, and any other functions that the compiler considers suitable for inlining.