Potential Differences Reporting
Generation of efficient C/C++ code from MATLAB® code sometimes results in behavior differences between the generated code and the MATLAB code. See Differences Between Generated Code and MATLAB Code.
When you run your program, run-time error checks can detect some of these differences. By default, run-time error checks are:
To help you identify and address differences before you deploy code, the code generator reports a subset of the differences as potential differences. A potential difference is a difference that occurs at run time only under certain conditions.
Addressing Potential Differences Messages
If the code generator detects a potential difference, it displays a message for the difference on the Potential Differences tab of the code generation report. See Code Generation Reports
The presence of a potential difference message does not necessarily mean that the difference will occur when you run the generated code. To determine whether the potential difference affects your application:
Analyze the behavior of your MATLAB code for the range of data for your application.
Test a MEX function generated from your MATLAB code. Use the range of data that your application uses. If the difference occurs, the MEX function reports an error.
If your analysis or testing confirms the reported difference, consider modifying your code. Some potential differences messages provide a workaround. For additional information about some of the potential differences messages, see Potential Differences Messages. Even if you modify your code to prevent a difference from occurring at run time, the code generator might still report the potential difference.
The set of potential differences that the code generator detects is a subset of the differences that MEX functions report as errors. It is a best practice to test a MEX function over the full range of application data.
Disabling and Enabling Potential Differences Reporting
Potential differences reporting is enabled by default for standalone and MEX code
generation whether you generate code by using the codegen
command at the command line or by using the MATLAB
Coder app.
To disable potential differences reporting:
In a code configuration object, set
ReportPotentialDifferences
tofalse
.In the Code Generation Settings dialog box, clear the Report differences from MATLAB check box.