SLAU132V October 2004 – February 2020
The FORCEINLINE pragma can be placed before a statement to force any function calls made in that statement to be inlined. It has no effect on other calls to the same functions.
The compiler only inlines a function if it is legal to inline the function. Functions are never inlined if the compiler is invoked with the --opt_level=off option. A function can be inlined even if the function is not declared with the inline keyword. A function can be inlined even if the compiler is not invoked with any --opt_level command-line option.
The syntax of the pragma in C/C++ is:
#pragma FORCEINLINE |
For example, in the following example, the mytest() and getname() functions are inlined, but the error() function is not.
#pragma FORCEINLINE
if (!mytest(getname(myvar))) {
error();
}
Placing the FORCEINLINE pragma before the call to error() would inline that function but not the others.
For information about interactions between command-line options, pragmas, and keywords that affect inlining, see Section 2.11.
Notice that the FORCEINLINE, FORCEINLINE_RECURSIVE, and NOINLINE pragmas affect only the C/C++ statement that follows the pragma. The FUNC_ALWAYS_INLINE and FUNC_CANNOT_INLINE pragmas affect an entire function.