Even with __forceinline, the compiler cannot inline code in all circumstances. The compiler cannot inline a function if:
1. The function or its caller is compiled with /Ob0 (the default option for debug builds).
2. The function and the caller use different types of exception handling (C++ exception handling in one, structured exception handling in the other).
3. The function has a variable argument list.
4. The function uses inline assembly, unless compiled with /Og, /Ox, /O1, or /O2.
5. The function is recursive and not accompanied by #pragma inline_recursion(on). With the pragma, recursive functions are inlined to a default depth of 16 calls. To reduce the inlining depth, use inline_depth pragma.
6. The function is virtual and is called virtually. Direct calls to virtual functions can be inlined.
7. The program takes the address of the function and the call is made via the pointer to the function. Direct calls to functions that have had their address taken can be inlined.
8. The function is also marked with the naked __declspec modifier.
Partager