With regards to optimization, by default the compiler optimizes for performance
with respect to time. If the compiler decides to inline a function, it makes sure to
avoid large code growth. When compiling with respect to restraining code size,
through use of
-Os, the compiler makes sensible decisions about inlining, aiming to
keep code size to a minimum.
In most circumstances, the decision to inline a particular function is best
left to the compiler. Qualifying a function with the
inline keywords suggests to the compiler that
it inlines that function, but the final decision rests with the compiler. Qualifying
a function with
__attribute((always_inline)) forces the compiler to inline
The linker is able to apply some degree of function inlining to
functions that are very short.
The default semantic rules for C-source code follow C99 rules. For inlining,
it means that when you suggest a function is inlined, the compiler expects to
find another, non-qualified, version of the function elsewhere in the code, to
use when it decides not to inline. If the compiler cannot find the non-qualified
version, it fails with the following error:
"Error: L6218E: Undefined symbol <symbol> (referred from <file>)".
To avoid this problem, there are several options:
- Provide an equivalent, non-qualified version of the function.
- Change the qualifier to
- Remove the
inline keyword, since it is only acting as a suggestion.
- Compile your program using the GNU C90 dialect, using the