Main Content

Reserved Identifiers and Code Replacement

The code generator and C programming language use, internally, reserved keywords for code generation. Do not use reserved keywords as identifiers or function names. Reserved keywords for code generation include many code replacement library identifiers, the majority of which are function names, such as acos.

To view a list of reserved identifiers for the code replacement library that you use to generate code, specify the name of the library in a call to the function RTW.TargetRegistry.getInstance.getTflReservedIdentifiers. For example:

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

In a code replacement table, the code generator registers each function implementation name defined by a table entry as a reserved identifier. You can register additional reserved identifiers for the table on a per-header-file basis. Providing additional reserved identifiers can help prevent duplicate symbols and other identifier-related compile and link issues.

To register additional code replacement reserved identifiers, use the setReservedIdentifiers function. This function registers specified reserved identifiers to be associated with a code replacement table.

You can register up to four reserved identifier structures in a code replacement table. You can associate one set of reserved identifiers with a code replacement library, while the other three (if present) must be associated with ANSI® C. The following example shows a reserved identifier structure that specifies two identifiers and the associated header file.

d{1}.LibraryName = 'ANSI_C';
d{1}.HeaderInfos{1}.HeaderName = 'math.h';
d{1}.HeaderInfos{1}.ReservedIds = {'y0', 'y1'};

The code generator adds the identifiers to the list of reserved identifiers and honors them during the build procedure.

Related Topics