Detect and Debug Code Generation Errors
Debugging Strategies
To prepare your algorithms for code generation, MathWorks® recommends that you choose a debugging strategy for detecting and correcting violations in your MATLAB® applications, especially if they consist of a large number of MATLAB files that call each other's functions. Here are two best practices:
Debugging Strategy | What to Do | Pros | Cons |
---|---|---|---|
Bottom-up verification |
|
| Requires application tests that work from the bottom up |
Top-down verification |
| Lets you retain your top-level tests | Introduces extraneous code that you must remove after code verification, including:
|
Error Detection at Design Time
To detect potential issues for MEX file building as you write your MATLAB algorithm, add the %#codegen
directive to the code that you
want fiaccel
to compile. Adding this directive indicates that you
intend to generate code from the algorithm and turns on detailed diagnostics during
MATLAB code analysis.
Error Detection at Compile Time
Before you can successfully generate code from a MATLAB algorithm, you must verify that the algorithm does not contain syntax and semantics violations that would cause compile-time errors, as described in Detect and Debug Code Generation Errors.
fiaccel
checks for all potential syntax violations at compile time.
When fiaccel
detects errors or warnings, it automatically produces a
code generation report that describes the issues and provides links to the offending code.
See Code Generation Reports.
If your MATLAB code calls functions on the MATLAB path, fiaccel
attempts to compile these functions unless
you declare them to be extrinsic.