Specify Data Types Used in Generated Code
MATLAB®
Coder™ can use built-in C data types or predefined types from
rtwtypes.h
in generated code. By default, when the generated code
declares variables, it uses built-in C types.
You can explicitly specify the data types used in generated code in the project settings dialog box or at the command line.
Specify Data Type Using the MATLAB Coder 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
, orExecutable
(depending on your requirements).Click More Settings.
To use built-in C types, on the Code Appearance tab, set Data Type Replacement to
Use built-in C data types
. To use predefined types fromrtwtypes.h
, set Data Type Replacement toUse coder typedefs
.
Specify Data Type 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');
To use built-in C types, set the
DataTypeReplacement
property to'CBuiltIn'
.cfg.DataTypeReplacement = 'CBuiltIn';
To use predefined types from
rtwtypes.h
, set theDataTypeReplacement
property to'CoderTypedefs'
.