You copied the Doc URL to your clipboard.

__attribute__((always_inline)) function attribute

This function attribute indicates that a function must be inlined.

The compiler attempts to inline the function, regardless of the characteristics of the function.

In some circumstances, the compiler might choose to ignore __attribute__((always_inline)), and not inline the function. For example:

  • A recursive function is never inlined into itself.
  • Functions that use alloca() might not be inlined.

Example

static int max(int x, int y) __attribute__((always_inline));
static int max(int x, int y)
{
    return x > y ? x : y; // always inline if possible
}

Note

__attribute__((always_inline)) does not affect the linkage characteristics of the function in the same way that the inline function-specifier does. When using __attribute__((always_inline)), if you want the declaration and linkage of the function to be governed by the rules of the inline function-specifier of the source language, then you must also use the keyword inline or __inline__ (for C90). For example:

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