The CC-RH allows inline expansion of each function. This section explains how to specify inline expansion.
Inline expansion is used to expand the main body of a function at a location where the function is called. This decreases the overhead of function call and increases the possibility of optimization. As a result, the execution speed can be increased.
If inline expansion is executed, however, the object size increases.
Specify the function to be expanded inline using the #pragma inline directive.
Describe functions that are described in the C language. In the case of a function, "void func1() {}", specify "func1". Two or more function names can be specified with each delimited by "," (comma).
#pragma inline func1, func2 void func1() {...} void func2() {...} void func(void) { func1(); /*function subject to inline expansion*/ func2(); /*function subject to inline expansion*/ } |
At least the following conditions must be satisfied for inline expansion of a function specified using the #pragma inline directive.
Inline expansion may not be executed even if the following conditions are satisfied, because of the internal processing of the CC-RH.
A function that expands inline and a function that is expanded inline are described in the same file |
A function that expands inline and a function that is expanded inline, i.e., a function call and a function definition must be in the same file. This means that a function described in another C source cannot be expanded inline. If it is specified that a function described in another C source is expanded inline, the CC-RH does not output a warning message and ignores the specification.
If the #pragma inline directive is described after function definition, the CC-RH outputs a warning message and ignores the specification. However, prototype declaration of the function may be described in any order. Here is an example.
The number of arguments is the same between "call" and "definition" of the function to be expanded inline. |
If the number of arguments is different between "call" and "definition" of the function to be expanded inline, the CC-RH ignores the specification.
The types of return value and argument are the same between "call" and "definition" of the function to be expanded inline. |
If the number of arguments is different between "call" and "definition" of the function to be expanded inline, the CC-RH ignores the specification. If the type of the argument is the integer type (including enum) or pointer-type, and in the same size, however, inline expansion is executed.
If inline expansion is specified for a function with a variable arguments, the CC-RH outputs neither an error nor warning message and ignores the specification.
If a recursive function that calls itself is specified for inline expansion, the CC-RH outputs neither an error nor warning message and ignores the specification. If two or more function calls are nested and if a code that calls itself exists, however, inline expansion may be executed.
If you call a function for inline expansion via its address, then the inline expansion specification will be ignored, without outputting an error or warning message.
If you specify -Xmerge_files, then functions may be inlined even if they are not coded within the file. |
When using the -Oinline option, use #pragma noinline to prevent inline expansion of a specific function.
#pragma inline_asm, #pragma inline, #pragma noinline, #pragma interrupt,
#pragma block_interrupt, #pragma stack_protector,
#pragma inline_asm, #pragma inline, #pragma noinline, #pragma interrupt,
Here are differences in inline expansion operation depending on whether the #pragma inline directive or an option is specified.