Specifying inline function (__inline)


This notifies the compiler of an inline function.

[Function]

-

The compiler inline-expands the function declared with __inline whenever possible.

-

If both #pragma noinline and __inline are specified for the same function within a single translation unit, an error will occur.

-

The conditions for the functions to be expanded inline depend on the -Oinline_level option setting.
For the effect of this option, see the "-Oinline_level" description in the "2.5.1 Compile options".

-

The function declared with __inline is expanded inline at the location from which the function is called.

-

If the call and definition of the specified function differ in either of the following ways, a warning message will be output and inline specification will be ignored.

-

The numbers of parameters do not match.

-

The types of the return values or parameters do not match and type conversion is not possible.
When type conversion is possible, the type is converted and then the function is expanded inline.
In this case, the type of the return value is converted to that on the caller side and the types or parameters are converted to those in the function definition.
Note that when the -strict_std option is specified, an error will occur even in this case.


-

If the specified function satisfies any of the following conditions, inline specification will be ignored; no message will be output in this case.

-

The function has variable arguments.

-

The function calls itself during processing.

-

A call is done through the address of the function to be expanded inline.

[Effect]

-

The function call and the code for returning to the caller are not output and execution is accelerated.

-

As the inline-expanded code is optimized as well as the code before and after the function call, the effect of optimization may be improved.

-

When the number of inline expansions is large, the code size may increase.

[Usage]

-

Add __inline to the definition of a function.

[Example]

extern int      gi;
__inline int    i_func(int i)
{
        return ++i;
}
 
void func(int j)
{
        gi = i_func(j);
}

[Caution]

-

Use of __inline does not guarantee inline expansion. The compiler may stop inline expansion depending on a limitation due to increased compilation time or memory usage

-

When the -lang=c99 option is specified, the keyword __inline is a separate name from the keyword inline; this is for compliance with the specification of inline for C99.