As a general rule, when compiling with
-Ospace, the compiler makes sensible decisions about inlining with a view to
producing code of minimal size. This is because code size for embedded systems is of
fundamental importance. When compiling with
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. However, you can give the
compiler a hint that a function is required to be inlined by using
the appropriate inline keyword.
Functions that are qualified with the
__forceinline keywords are called inline functions.
In C++, member functions that are defined inside a class, struct,
or union, are also inline functions.
The compiler also offers a range of other facilities for modifying
its behavior with respect to inlining. There are several factors
you must take into account when deciding whether to use these facilities,
or more generally, whether to inline a function at all.
The linker is able to apply some degree of function inlining
to functions that are very short.