Main Content

addDefines

Add preprocessor macro definitions to build information

Description

addDefines(buildinfo,macrodefs,groups) specifies the preprocessor macro definitions to add to the build information.

The function requires the buildinfo and macrodefs arguments. You can use an optional groups argument to group your options.

The code generator stores the definitions in a build information object. The function adds definitions to the object based on the order in which you specify them.

example

Examples

collapse all

Add a macro definition -DPRODUCTION to the build information myBuildInfo and place the definition in the group OPTS.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo,'-DPRODUCTION','OPTS');

Add a macro definition MYDEF with value MYVAL.

addDefines(myBuildInfo,'-MYDEF=MYVAL','OPTS');

Add a macro definition MYDEF with empty value.

addDefines(myBuildInfo,'-MYDEF=','OPTS');

Add a macro definition MYDEF with undefined value.

addDefines(myBuildInfo,'-MYDEF','OPTS');

Add the macro definitions -DPROTO and -DDEBUG to the build information myBuildInfo and place the definitions in the group OPT_OPTS.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo, ...
  '-DPROTO -DDEBUG','OPT_OPTS');

For a non-makefile build environment, add the macro definitions -DPROTO, -DDEBUG, and -DPRODUCTION to the build information myBuildInfo. Place the definitions -DPROTO and -DDEBUG in the group Debug and the definition -DPRODUCTION in the group Release.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo, ...
  {'-DPROTO -DDEBUG' '-DPRODUCTION'}, ...
  {'Debug' 'Release'});

Input Arguments

collapse all

Object contains information for compiling and linking generated code.

You can specify the macrodefs argument as a character vector, as an array of character vectors, or as a string. You can specify the macrodefs argument as multiple definitions within a single character vector, for example '-DRT -DDEBUG'. If you specify the macrodefs argument as multiple character vectors, for example'-DPROTO -DDEBUG' and '-DPRODUCTION', the macrodefs argument is added to the build information as an array of character vectors.

Example: {'-DPROTO -DDEBUG' '-DPRODUCTION'}

You can specify the groups argument as a character vector, as an array of character vectors, or as a string. If you specify multiple groups, for example 'Debug' 'Release', the function relates the groups to the macrodefs in order of appearance. For example, the macrodefs argument {'-DPROTO -DDEBUG' '-DPRODUCTION'} is an array of character vectors with two elements. The first element is in the 'Debug' group and the second element is in the 'Release' group.

Note

The template makefile-based build process considers only macro definitions in the 'OPTS', 'OPT_OPTS', 'OPTIMIZATION_FLAGS', and 'Custom' groups when generating the makefile.

For the build process to consider definitions in other groups, the template makefile must contain the token |>DEFINES_OTHER<|.

Example: {'Debug' 'Release'}

Version History

Introduced in R2006a