Main Content

Reserved Keywords

The code generator reserves the use of certain identifiers in the generated code. These identifiers include C and C++ keywords and C and C++ standard library names. Using these keywords in your MATLAB® code as identifiers or function names might cause the code generator to rename them. If you do not find variables or functions that have reserved keywords as names in your generated code, they might have been renamed by the code generator.

Note

You can preserve most variable names, apart from the reserved keywords, in your generated code. See Preserve Variable Names in Generated Code.

C Reserved Keywords

_Bool_Complex_Generic_Imaginary
_Noreturn_Static_assert_Thread_localthreads
asmautoassertcase
charconstcontinuedefault
complexvoidtimetgmath
ctypeiso646stdatomicstddef
dodoubleelseenum
externfloatforgoto
ifinlineintlong
limitslocalestdboolstdio
registerrestrictreturnshort
signalwctypesetjmpstring
signedsizeofstaticstruct
single_Alignas_Alignof_Atomic
stdaligninttypesstdarguchar
stdintmatherrnowchar
stdlibstdnoreturnbreakfenv
switchtypedeftypeofunion
truefalseboolfortran
unsignedwhilevolatile 

C++ Reserved Keywords

algorithmcstddefiostreamsstream
anycstdintistreamstack
arraycstdioiteratorstatic_cast
atomiccstdliblimitsstdexcept
bitsetcstringliststreambuf
cassertctgmathlocalestring_view
catchctimemapstrstream
ccomplexcucharmemorysystem_error
cctypecwcharmemory_resourcetemplate
cerrnocwctypemutablethis
cfenvdeletemutexthread
cfloatdequenamespacethrow
chronodynamic_castnewtry
cinttypesexceptionnumerictuple
ciso646executionoperatortypeid
classexplicitoptionaltype_traits
climitsexportostreamtypeindex
clocalefilesystemprivatetypeinfo
cmathforeward_listprotectedtypename
codecvtfriendpublicunordered_map
complexfstreamqueueunordered_set
condition_variablefunctionalrandomusing
const_castfutureratioutility
csetjmpinitializer_listregexvalarray
csignalinlinereinterpret_castvector
cstdaligniomanipscoped_allocatorvirtual
cstdargiossetwchar_t
cstdbooliosfwdshared_mutex 

Keywords Reserved for Code Generation

absfortranlocalZCErtNaN
asmHAVESTDIOlocalZCSVSeedFileBuffer
boolid_tmatrixSeedFileBufferLen
boolean_Tint_TMODELsingle
byte_T int8_TMTTID01EQ
char_Tint16_TNCSTATEStime_T
cint8_Tint32_TNULLtrue
cint16_Tint64_TNUMSTTRUE
cint32_TINTEGER_CODEpointer_Tuint_T
creal_TLINK_DATA_BUFFER_SIZEPROFILING_ENABLED uint8_T
creal32_TLINK_DATA_STREAMPROFILING_NUM_SAMPLESuint16_T
creal64_TlocalBreal_Tuint32_T
cuint8_TlocalCreal32_Tuint64_T
cuint16_TlocalDWorkreal64_TUNUSED_PARAMETER
cuint32_TlocalPRTUSE_RTMODEL
ERTlocalXRT_MALLOC VCAST_FLUSH_DATA
falselocalXdisrtInfvector
FALSElocalXdotrtMinusInf 

Some identifiers from the C/C++ standard libraries such as fprintf, freadf, and I are also reserved.

If you include these names in your MATLAB code as identifiers, they are renamed in the generated code by prepending a letter in front of the name. For example, asm might be renamed as b_asm.

This code snippet uses an input and output variable that is named real_T, which is a reserved keyword for code generation.

function real_T = foo(real_T)
real_T = real_T + 1;
end

In the generated code, the variable real_T is renamed to b_real_T.

void foo(double *b_real_T)
{
  (*b_real_T)++;
}

Reserved Prefixes

MATLAB Coder™ reserves the prefix eml for global C/C++ functions and variables in generated code. For example, MATLAB for code generation run-time library function names begin with the prefix emlrt, such as emlrtCallMATLAB. To avoid naming conflicts, do not name C/C++ functions or primary MATLAB functions with the prefix eml.

MATLAB Coder Code Replacement Library Keywords

The list of code replacement library (CRL) reserved keywords for your development environment varies depending on which CRLs currently are registered. Beyond the default ANSI®, ISO®, and GNU® CRLs provided with MATLAB Coder software, additional CRLs might be registered and available for use if you have installed other products that provide CRLs (for example, a target product), or if you have used Embedded Coder® APIs to create and register custom CRLs.

To generate a list of reserved keywords for the CRLs currently registered in your environment, use the following MATLAB function:

crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers()

This function returns a cell array of character vectors that contain CRL keywords. Specifying the return argument is optional.

Note

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

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

crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)')

Here is a partial example of the function output:

>> crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)')

crl_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.

Programmatically Retrieve Lists of 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.

See Also

Related Topics