Main Content

Reserved Keywords

Generator keywords are reserved for internal use. Do not use them in models as identifiers or function names. Also avoid using C reserved keywords in models as identifiers or function names. If your model contains reserved keywords, the code generator attempts to replace those keywords when it generates identifiers in the code. If the code generator cannot replace the reserved keyword, then the generated code uses reserved keywords as identifiers and might not compile. To avoid generating identifiers that do not match identifiers in your model, do not use reserved keywords as identifiers.

C Reserved Keywords

These are the reserved keywords that the C language specifies. The code generator attempts to rename identifiers that match these keywords.

autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
constfloatshortunsigned
continueforsignedvoid
defaultgotosizeofvolatile
doifstaticwhile

C++ Reserved Keywords

These are the reserved keywords that the C++ language specifies in addition to the C reserved keywords. If you generate C++ code, the code generator attempts to rename identifiers that match these keywords.

boolfalseprotectedtry
catchfriendpublictypeid
classinlinereinterpret_casttypename
const_castmutablestatic_castusing
deletenamespacetemplatevirtual
dynamic_castnewthiswchar_t
explicitoperatorthrow 
exportprivatetrue 

Other Common Reserved Keywords

The code generator attempts to replace some keywords that are not part of the C or C++ language specification. See examples of some of these keywords in this table.

absint8_TMAX_int64_TRT
arrayint16_TMAX_uint8_T*RT_MALLOC
asmint32_TMAX_uint16_T*rtInf
boolean_Tint64_TMAX_uint32_T*rtMinusInf
byte_TINTEGER_CODEMAX_uint64_TrtNaN
char_TLINK_DATA_BUFFER_SIZEMIN_int8_T*SeedFileBuffer
cint8_TLINK_DATA_STREAMMIN_int16_T*SeedFileBufferLen
cint16_TlocalBMIN_int32_T*single
cint32_TlocalCMIN_int64_TTID01EQ
creal_TlocalDWorkMODELtime_T
creal32_TlocalPMTtm
creal64_TlocalXNCSTATESuint_T
cuint8_TlocalXdisNULLuint8_T
cuint16_TlocalXdotNUMSTuint16_T
cuint32_TlocalZCEpointer_Tuint32_T
ERTlocalZCSVPROFILING_ENABLED uint64_T
fortranmatrixPROFILING_NUM_SAMPLESUNUSED_PARAMETER
HAVESTDIOMAX_int8_T*real_TUSE_RTMODEL
id_tMAX_int16_T*real32_TVCAST_FLUSH_DATA
int_TMAX_int32_T*real64_Tvector
*Not reserved if you specify a replacement identifier.

Code Generation Code Replacement Library Keywords

The list of code replacement library reserved keywords for your development environment varies depending on which libraries are registered. The list of available code replacement libraries varies depending on other installed products (for example, a target product), or if you used Embedded Coder® to create and register custom code replacement libraries.

To generate a list of reserved keywords for libraries currently registered in your environment, use this MATLAB® function:

lib_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers()

This function returns an array of library keywords. Specifying the input argument is optional.

Note

To list the libraries currently registered in your environment, use the MATLAB command crviewer.

To generate a list of reserved keywords for a specific library that you are using to generate code, call the function passing the name of the library as displayed in the Code replacement library menu on the Code Generation > Interface pane of the Configuration Parameters dialog box. For example,

lib_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU C99 extensions')

Here is a partial example of the function output:

>> lib_ids = ...
   RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU C99 extensions')

lib_ids = 

    'exp10'
    'exp10f'
    'acosf'
    'acoshf'
    'asinf'
    'asinhf'
    'atanf'
    'atanhf'
...
    'rt_lu_cplx'
    'rt_lu_cplx_sgl'
    'rt_lu_real'
    'rt_lu_real_sgl'
    'rt_mod_boolean'
    'rt_rem_boolean'
    'strcpy'
    'utAssert'

Note

Some of the returned keywords appear with the suffix $N, for example, 'rt_atan2$N'. $N expands into the suffix _snf only if nonfinite numbers are supported. For example, 'rt_atan2$N' represents 'rt_atan2_snf' if nonfinite numbers are supported and 'rt_atan2' if nonfinite numbers are not supported. As a precaution, you should treat both forms of the keyword as reserved.

Specify Custom Reserved Keywords

You can specify a set of custom reserved keywords in addition to those that the code generator reserves. Specify custom reserved keywords to facilitate code integration where functions and variables from external environments are unknown in the Simulink® model.

To create a list of reserved names, open the Configuration Parameters dialog box. On the Code Generation > Identifiers pane, enter the keywords in the Reserved names field.

If your model contains MATLAB Function or Stateflow® blocks, the code generation process uses the reserved names specified for those blocks if you select Use the same reserved names as Simulation Target on the Code Generation > Identifiers pane.

Programmatically Check Reserved Keywords

Because the list of reserved keywords is large and dynamic, the documentation cannot display it in full. To programmatically retrieve the list of keywords that the code generator attempts to replace, run this command from the MATLAB Command Window:

RTW.reservedIdentifiers()
The command returns structures that contain lists of reserved identifiers. For more information about the return values, see RTW.reservedIdentifiers.

If you have a Simulink Check™ license, you can use the Check model object names (Simulink Check) check to verify that a model does not use reserved names.

See Also