Main Content

coder.updateTlcForLanguageStandardTypes

Modify TLC file containing hard-coded Simulink Coder data types for compatibility with DataTypeReplacement=CDataTypesFixedWidth code generation

Since R2023a

    Description

    coder.updateTlcForLanguageStandardTypes(tlcFile) updates the input TLC file, which contains hard-coded instances of Simulink® Coder™ data types, for compatibility with DataTypeReplacement=CDataTypesFixedWidth code generation. In the TLC file, the function replaces the hard-coded instances of CoderTypedef names (for example, real32_T) with corresponding API calls. During code generation, the updated TLC code emits:

    • C99 data types if the value of the DataTypeReplacement configuration parameter is 'CDataTypesFixedWidth'.

    • Simulink Coder data types if the DataTypeReplacement configuration parameter is 'CoderTypedefs'.

    The function does not update hard-coded data types that are used as a case value within a switch statement. In this instance, manually update the lines of code. For example, in the switch expression, use the data type identifier instead of the data type name.

    Note

    Before generating code, in the modified TLC file, check the changes produced by the function. TLC files can be very complex. In some cases, the function updates might fail or introduce an error.

    example

    Examples

    collapse all

    This example shows how you can use coder.updateTlcForLanguageStandardTypes to update a TLC file that contains hard-coded instances of Simulink Coder data types.

    Copy the TLC file to your working folder. For example, copy the sldemo_sfun_dlut3D.tlc file from a release before R2023a.

    matlabRootForR2021b='C:\Program Files\MATLAB\R2021b';
    tlcFilePath=['\examples\simulink_features' ...
                 '\data\sldemo_sfun_dlut3D.tlc'];
    copyfile([matlabRootForR2021b tlcFilePath], '.');

    Make the file writable.

    fileattrib('sldemo_sfun_dlut3D.tlc', '+w');

    Run the function.

    coder.updateTlcForLanguageStandardTypes('sldemo_sfun_dlut3D.tlc');
    File
    
       sldemo_sfun_dlut3D.tlc
    
    was updated to support language standard types
    Created backup file:
    
        sldemo_sfun_dlut3D.bak
    Please review differences between the two files.

    Click the review differences link. The Comparison Tool displays the differences between the updated file and the backup file that contains the original code.

    Observe, for example, that the call to the singleType function replaces the Simulink Coder data type real32_T.

    Input Arguments

    collapse all

    Name of TLC file that contains hard-coded instances of Simulink Coder data types.

    Example: 'sldemo_sfun_dlut3D.tlc'

    Data Types: char | string

    Version History

    Introduced in R2023a