Main Content

getDefines

Get preprocessor macro definitions from build information

Description

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

example

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.

Group names of macro definitions to include in the return from the function, specified as a string or a cell array of character vectors. To view the group name of a macro definition, access the Group property of the corresponding object.

Example: ''

Group names of macro definitions to exclude from the return from the function, specified as a string or a cell array of character vectors. To view the group name of a macro definition, access the Group property of the corresponding object.

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