Main Content

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

  1. To open the Generate dialog box, on the Generate Code page, click the Generate arrow .

  2. Set Build type to Source Code, Static Library, Dynamic Library, or Executable (depending on your requirements).

  3. Click More Settings.

  4. 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 from rtwtypes.h, set Data Type Replacement to Use coder typedefs.

Specify Data Type at the Command Line

  1. 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');
  2. To use built-in C types, set the DataTypeReplacement property to 'CBuiltIn'.

    cfg.DataTypeReplacement = 'CBuiltIn';

    To use predefined types from rtwtypes.h, set the DataTypeReplacement property to 'CoderTypedefs'.