gnu_inline (IBM extension)

The gnu_inline attribute instructs the compiler to modify the inlining behavior of a function. When this function attribute is used, the compiler imitates the GNU legacy inlining extension to C.

This function attribute is only enabled if used in conjunction with an inline keyword (__inline__, inline, __inline, etc.).
Read syntax diagramSkip visual syntax diagram
gnu_inline function attribute syntax

>>-inline--__attribute__--((----gnu_inline----))---------------><

Note: The behavior of the gnu_inline function attribute is the same when used in conjunction with either the inline or __inline__ keywords.
The semantics of the GNU legacy inlining extension to C are as follows:
C only begins
extern gnu_inline:
extern inline __attribute__((gnu_inline)) func() {…};
This definition of func is used only for inlining. It is not compiled as a standalone function.
static gnu_inline:
static inline __attribute__((gnu_inline)) func() {…};
If the function is generated, it is generated with internal linkage.
plain gnu_inline:
inline __attribute__((gnu_inline)) func() {…};
The definition is used for inlining when possible. It is compiled as a standalone function (emitted as a strong definition) and emitted with external linkage.
C only ends
C++ only begins
extern gnu_inline:
[extern] inline __attribute__((gnu_inline)) func() {…};
This definition of func is used only for inlining. It is not compiled as a standalone function. Note that member functions (including static ones and ones with no linkage) marked with function attribute gnu_inline has "extern" behavior.
static gnu_inline:
static inline __attribute__((gnu_inline)) func() {…};
If the function is generated, it is generated with internal linkage. Note that static behavior only applies to non-member static functions.
C++ only ends
The gnu_inline attribute can be specified inside double parentheses with keyword __attribute__ in a function declaration. See the following example.

inline int func() __attribute__((gnu_inline));

As with other GCC function attributes, the double underscores on the attribute name are optional. The gnu_inline attribute should be used with a function that is also declared with the inline keyword.