9.6 __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 a function qualified as __forceinline, regardless of its characteristics. However, the compiler does not inline a function if doing so causes problems. For example, a recursive function is inlined into itself only once.
__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)).

Examples

__forceinline static int max(int x, int y)
{
    return x > y ? x : y; // always inline if possible
}
Related reference
9.32 __attribute__((always_inline)) function attribute
7.63 --forceinline
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.