Main Content

registerCPromotableMacroEntry

Create promotable code replacement macro entry based on specified parameters and register in code replacement table (for abs function replacement only)

Description

example

entry = registerCPromotableMacroEntry(hTable,priority,numInputs,functionName,inputType,implementationName,outputType,headerFile,genCallback,genFileName) creates a promotable macro entry based on specified parameters and registers the entry in the code replacement table. A promotable macro entry promotes the output data type based on the target word size.

This function provides a quick way to create and register a promotable macro entry. This function can be used only if your code replacement function entry meets the following conditions:

  • The input arguments are of the same type.

  • The input argument names and the return argument name follow the default Simulink® naming convention:

    • For input argument names, u1, u2, ..., un

    • For return argument, y1

Use this function only for abs function replacement. For other functions supported for replacement, use registerCFunctionEntry.

Examples

collapse all

This example shows how to use the registerCPromotableMacroEntry function to create a promotable macro entry for abs in a code replacement table.

hLib = RTW.TflTable;

hLib.registerCPromotableMacroEntry(100, 1, 'abs', ...
    'double', 'abs_prime', ...
    'double', '<math_prime.h>', '', '');

Input Arguments

collapse all

The hTable is a handle to a code replacement table previously returned by hTable = RTW.TflTable.

Example: hLib

The priority specifies the search priority for the function entry, relative to other entries of the same function name and conceptual argument list within this table. Highest priority is 0, and lowest priority is 100. If the table provides two implementations for a function, the implementation with the higher priority shadows the one with the lower priority.

Example: 100

Example: 1

The functionName specifies the name of the function to be replaced. Specify 'abs'. Use this function only for abs function replacement.

Example: 'abs'

This function requires that the input arguments are of the same type.

Example: 'double'

The implementationName specifies the name of the implementation. For example, assuming functionName is 'abs', implementationName can be 'abs' or a different name of your choosing.

Example: 'abs'

Example: 'double'

Example: '<math.h>'

The genCallback specifies a callback that follows code generation. If you specify 'RTW.copyFileToBuildDir', and if this function entry is matched and used, the code generator calls function RTW.copyFileToBuildDir after code generation. This callback function copies additional header, source, or object files that you have specified for this function entry to the build folder.

Example: ''

This argument is reserved for MathWorks developers.

Example: ''

Output Arguments

collapse all

The entry is a handle to the created promotable macro entry. Specifying the return argument in the registerCPromotableMacroEntry function call is optional.

Introduced in R2007b