You copied the Doc URL to your clipboard.


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.


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


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