The FUNC_ALWAYS_INLINE Pragma

The FUNC_ALWAYS_INLINE pragma instructs the compiler to always inline the named function.

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. See Section 2.11 for details about interaction between various types of inlining.

This pragma must appear before any declaration or reference to the function that you want to inline. In C, the argument func is the name of the function that will be inlined. In C++, the pragma applies to the next function declared.

This pragma can be used to force inlining at link time across C files.

The FUNC_ALWAYS_INLINE pragma has the same effect as using the GCC-style always_inline function attribute. See Section 5.17.2.

The syntax of the pragma in C is:

#pragma FUNC_ALWAYS_INLINE (func)

The syntax of the pragma in C++ is:

#pragma FUNC_ALWAYS_INLINE

The following example uses this pragma:

#pragma FUNC_ALWAYS_INLINE(functionThatMustGetInlined) static inline void functionThatMustGetInlined(void) { P1OUT |= 0x01; P1OUT &= ~0x01; }

NOTE

Use Caution with the FUNC_ALWAYS_INLINE Pragma

The FUNC_ALWAYS_INLINE pragma overrides the compiler's inlining decisions. Overuse of this pragma could result in increased compilation times or memory usage, potentially enough to consume all available memory and result in compilation tool failures.