A.2.2 Performing In-Line Expansion of Functions

#pragma inline declares a function for which inline expansion is performed.

The compiler options inline and noline are also used to enable or disable inline expansion. However, even when the noinline option is specified, inline expansion is done for the function specified by #pragma inline.

A global function or a static function member can be specified as a function name. A function specified by #pragma inline or a function with specifier inline (C++ and C (C99)) are expanded where the function is called.

[Example]

C source code

#pragma inline(func)
static int func (int a, int b)
{
     return (a+b)/2;
}
int x;
main()
{
     x=func(10,20);
}

 

Expanded image

int x;
main()
{
     int func_result;
     {
          int a_1=10, b_1=20;
          func_result=(a_1+b_1)/2;
     }
     x=func_result;
}