You copied the Doc URL to your clipboard.

Inline functions

Inline functions offer a trade-off between code size and performance. By default, the compiler decides for itself whether to inline code or not.

As a rule, when compiling with -Ospace, the compiler makes sensible decisions about inlining with a view to producing code of minimal size. When compiling with -Otime, the compiler inlines in most cases, but still avoids large code growth.

In most circumstances, the decision to inline a particular function is best left to the compiler. Qualifying a function with the __inline__ or 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 function.

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 that 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 static inline.
  • Remove the inline keyword, since it is only acting as a suggestion.
  • Compile your program using the GNU C90 dialect, using the -std=gnu90 option.