Specifies the inline heuristic search depth, such that, no function will be inlined if it is at a depth (in the call graph) greater than n.

#pragma inline_depth( [n] )

This pragma controls the inlining of functions marked inline and __inline or inlined automatically under the /Ob2 option.

n can be a value between 0 and 255, where 255 means unlimited depth in the call graph, and zero inhibits inline expansion. When n is not specified, the default (254) is used.

The inline_depth pragma controls the number of times a series of function calls can be expanded. For example, if the inline depth is four, and if A calls B and B then calls C, all three calls will be expanded inline. However, if the closest inline expansion is two, only A and B are expanded, and C remains as a function call.

To use this pragma, you must set the /Ob compiler option to 1 or 2. The depth set using this pragma takes effect at the first function call after the pragma.

The inline depth can be decreased during expansion but not increased. If the inline depth is six and during expansion the preprocessor encounters an inline_depth pragma with a value of eight, the depth remains six.

The inline_depth pragma has no effect on functions marked with __forceinline.


Recursive functions can be substituted inline to a maximum depth of 16 calls.

Community Additions