The code generator produces supporting code for the following situations:
The result of an integer operation falls outside the range that a data type can represent. This situation is known as integer overflow.
An operation generates non-finite values (inf
and NaN
).
The supporting code is contained in the files rt_nonfinite.c
, rtGetInf.c
,
and rtGetNaN.c
(with corresponding header files).
If you know that these situations do not occur, you can suppress generation of the supporting code. You therefore reduce the size of the generated code and increase its speed. However, if one of these situations occurs, it is possible that the generated code does not match the behavior of the original MATLAB® code.
You can use the MATLAB Coder™ app or the command-line interface to disable support for integer overflow. When you disable this support, the overflow behavior of your generated code depends on your target C compiler. Most C compilers wrap on overflow.
Using the app:
To open the Generate dialog
box, on the Generate Code page, click the Generate arrow
.
Click More Settings.
On the Speed tab, clear Saturate
on integer overflow
.
At the command line:
Create a configuration object for code generation.
Use coder.config
with arguments 'lib'
, 'dll'
,
or 'exe'
(depending on your requirements). For
example:
cfg = coder.config('lib');
Set the SaturateOnIntegerOverflow
property
to false
.
cfg.SaturateOnIntegerOverflow = false;
You can use the MATLAB Coder app or the command-line interface
to disable support for non-finite numbers(inf
and NaN
).
Using the app:
To open the Generate dialog
box, on the Generate Code page, click the Generate arrow
.
Set Build type to Source
Code
, Static Library
, Dynamic
Library
, or Executable
(depending
on your requirements).
Click More Settings.
On the Speed tab, clear the Support non-finite numbers check box.
At the command line:
Create a configuration object for code generation.
Use coder.config
with arguments 'lib'
, 'dll'
,
or 'exe'
(depending on your requirements).
For example:
cfg = coder.config('lib');
Set the SupportNonFinite
property
to false
.
cfg.SupportNonFinite = false;