You copied the Doc URL to your clipboard.

__forceinline

The __forceinline keyword forces the compiler to compile a C or C++ function inline.

The semantics of __forceinline are exactly the same as those of the C++ inline keyword. The compiler attempts to inline the function regardless of its characteristics.

In some circumstances the compiler may choose to ignore the __forceinline keyword and not inline a function. For example:

  • A recursive function is never inlined into itself.
  • Functions making use of alloca() are never inlined.

__forceinline is a storage class qualifier. It does not affect the type of a function.

Note

This keyword has the function attribute equivalent __attribute__((always_inline)).

Example

__forceinline static int max(int x, int y)
{
    return x > y ? x : y; // always inline if possible
}
Was this page helpful? Yes No