coder.inline
Control inlining of a specific function in generated code
Description
coder.inline('always')
forces
inlining of the current function
in the generated code. Place the coder.inline
directive inside the
function that you want to inline. The code generator does not inline entry-point functions
and recursive functions. Also, the code generator does not inline functions into
parfor
loops, or inline functions called from
parfor
loops.
coder.inline('never')
prevents
inlining of the current function in the generated code. Prevent inlining when you want to
simplify the mapping between the MATLAB® source code and the generated code.
Note
If you use the codegen
(MATLAB Coder) or the fiaccel
(Fixed-Point Designer) command, you can disable inlining for
all functions by using the -O
disable:inline
option.
If you generate C/C++ code by using the codegen
command or the
MATLAB
Coder™ app, you might have different speed and readability requirements for the
code generated for functions that you write and the code generated for MathWorks® functions. Certain additional global settings enable you to separately
control the inlining behavior for these two parts of the generated code base and at the
boundary between them. See Control Inlining to Fine-Tune Performance and Readability of Generated Code (MATLAB Coder).
In cases where the code generator does not prevent inlining of a function in the
generated code even if it contains the coder.inline('never')
directive,
use the coder.ignoreConst
(MATLAB Coder) function on an input at the
function call site in your MATLAB code. For more information, see Resolve Issue: coder.inline('never') Does Not Prevent Inlining of Function (MATLAB Coder).
coder.inline('default')
instructs the code generator to use
internal heuristics to determine whether to inline the current function. Usually, the
heuristics produce highly optimized code. Use coder.inline
explicitly in
your MATLAB functions only when you need to fine-tune these optimizations.
Examples
More About
Extended Capabilities
Version History
Introduced in R2011a