coder.inline
Control inlining of current function in generated code
Syntax
Description
coder.inline(
controls the inlining of
the current function in the generated C/C++ code, as specified by
option
)option
.
coder.inline("always")
instructs the code generator to replace a function call with the contents (body) of the called function in the generated code.coder.inline("never")
prevents inlining of the current function in the generated code.coder.inline("default")
instructs the code generator to use internal heuristics to determine whether to inline the current function.
Inlining eliminates the overhead of a function call and can create opportunities for
further optimization of the generated code, but can generate larger, more complex code.
Conversely, preventing inlining can simplify the mapping between the MATLAB® code and the generated code. By default, the code generator uses internal
heuristics to determine whether to inline the current function. Usually, these heuristics
produce highly optimized code. Use the coder.inline
optimization
directive explicitly in your MATLAB functions only when you need to fine-tune these optimizations.
To control the inlining behavior of the code
generator at each individual call site, use coder.inlineCall
and
coder.nonInlineCall
.
Examples
Input Arguments
Tips
If you use the
codegen
(MATLAB Coder) or thefiaccel
(Fixed-Point Designer) command, you can disable inlining for all functions by using the-O disable:inline
option.You might have different speed and readability requirements for C/C++ code generated from functions that you write as compared to C/C++ code generated from MATLAB functions. Additional global settings enable you to control inlining for these two parts of the generated code base. See Control Inlining to Fine-Tune Performance and Readability of Generated Code (MATLAB Coder).