Main Content

getDefines

Get preprocessor macro definitions from build information

Description

example

[macrodefs,identifiers,values] = getDefines(buildinfo,includeGroups,excludeGroups) returns preprocessor macro definitions from the build information.

The function requires the buildinfo, macrodefs, identifiers, and values arguments. You can use optional includeGroups and excludeGroups arguments. These optional arguments let you include or exclude groups selectively from the preprocessor macro definitions returned by the function.

If you choose to specify excludeGroups and omit includeGroups, specify a null character vector ('') for includeGroups.

Examples

collapse all

Get the preprocessor macro definitions stored in the build information myBuildInfo.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'},'OPTS');
[defs,names,values] = getDefines(myBuildInfo);
>> defs

defs = 

    '-DPROTO=first'   '-DDEBUG'   '-Dtest'   '-DPRODUCTION'

>> names

names = 
 
    'PROTO'
    'DEBUG'
    'test'
    'PRODUCTION'

>> values

values = 

    'first'
    ''
    ''
    ''

Get the preprocessor macro definitions stored with the group name Debug in the build information myBuildInfo.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
   {'Debug' 'Debug' 'Debug' 'Release'});
[defs,names,values] = getDefines(myBuildInfo,'Debug');
>> defs

defs = 

    '-DPROTO=first'   '-DDEBUG'     '-Dtest'

Get the preprocessor macro definitions stored in the build information myBuildInfo, except those definitions with the group name Debug.

myBuildInfo = RTW.BuildInfo;
addDefines(myBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
   {'Debug' 'Debug' 'Debug' 'Release'});
[defs,names,values] = getDefines(myBuildInfo,'','Debug');
>> defs

defs = 

    '-DPRODUCTION'

Input Arguments

collapse all

RTW.BuildInfo object that contains information for compiling and linking generated code.

To use the includeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

To use the excludeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

Output Arguments

collapse all

The macrodefs provide the complete macro definitions with a -D prefix. When the function returns a definition:

  • If the -D was not specified when the definition was added to the build information, prepends a -D to the definition.

  • Changes a lowercase -d to -D.

The values provide anything specified to the right of the first equal sign in the macro definition. The default is an empty character vector ('').

Version History

Introduced in R2006a