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.).
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:
- extern gnu_inline:
This definition of func is used only for inlining. It is not compiled as a standalone function.extern inline __attribute__((gnu_inline)) func() {…};
static gnu_inline:
If the function is generated, it is generated with internal linkage.static inline __attribute__((gnu_inline)) func() {…};
plain gnu_inline:
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.inline __attribute__((gnu_inline)) func() {…};
- extern gnu_inline:
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.[extern] inline __attribute__((gnu_inline)) func() {…};
static gnu_inline:
If the function is generated, it is generated with internal linkage. Note that static behavior only applies to non-member static functions.static inline __attribute__((gnu_inline)) func() {…};
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.