_Inline, _inline, __inline (C Only)

The C compiler provides keywords that you can use to specify functions that you want the compiler to inline:

For example:

_Inline int catherine(int a);

causes catherine to be inlined, meaning that code is generated for the function, rather than a function call. The inline keywords also implicitly declare the function as static.

Using the inline specifiers with data generates an error.

By default, function inlining is turned off, and functions qualified with inline specifiers are treated simply as static functions. To turn on function inlining, specify either the -qinline or -Q compiler options in AIX. If you turn optimization on (/O+), /Oi+ becomes the default.

Recursive functions (functions that call themselves) are inlined for the first occurrence only. The call to the function from within itself is not inlined.

You can also use the -qinline or -Q compiler options in AIX to automatically inline all functions smaller than a specified size. For best performance, however, use the inline keywords to choose the functions you want to inline rather than using automatic inlining.

An inline function can be declared and defined simultaneously. If it is declared with one of the inline specifier keywords, it can be declared without a definition. The following code fragment shows an inline function definition. Note that the definition includes both the declaration and body of the inline function.

_inline int add(int i, int j) { return i + j; }

Note: The use of the inline specifier does not change the meaning of the function, but inline expansion of a function may not preserve the order of evaluation of the actual arguments.



Keywords in VisualAge C++