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
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.