| Real-Time Workshop® | ![]() |
Add preprocessor macro definitions to model's build information
addDefines(buildinfo, macrodefs, groups)
groups is optional.
Build information returned by RTW.BuildInfo.
A character array or cell array of character arrays that specifies the preprocessor macro definitions to be added to the object. The function adds each definition to the end of a compiler option vector. If you specify multiple definitions within a single character array, for example '-DRT -DDEBUG', the function adds the string to the vector as a single element. For example, if you add '-DPROTO -DDEBUG' and then '-DPRODUCTION', the vector consists of two elements, as shown below.
'-DPROTO -DDEBUG' '-DPRODUCTION'
A character array or cell array of character arrays that groups specified definitions. You can use groups to
Document the use of specific macro definitions
Retrieve or apply groups of macro definitions
You can apply
A single group name to an macro definition
A single group name to multiple macro definitions
Multiple group names to collections of multiple macro definitions
| To... | Specify groups as a... |
|---|---|
| Apply one group name to all macro definitions | Character array. To specify macro definitions to be used in the standard Real-Time Workshop® makefile build process, specify the character array 'OPTS' or 'OPT_OPTS'. |
| Apply different group names to macro definitions | Cell array of character arrays such that the number of group names matches the number elements you specify for macrodefs. Available for nonmakefile build environments only. |
The addDefines function adds specified preprocessor macro definitions to the model's build information. The Real-Time Workshop software stores the definitions in a vector. The function adds definitions to the end of the vector based on the order in which you specify them.
In addition to the required buildinfo and macrodefs arguments, you can use an optional groups argument to group your options.
Add the macro definition -DPRODUCTION to build information myModelBuildInfo and place the definition in the group Release.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, '-DPRODUCTION','Release');
Add the macro definitions -DPROTO and -DDEBUG to build information myModelBuildInfo and place the definitions in the group Debug.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, '-DPROTO -DDEBUG','Debug');
Add the compiler definitions -DPROTO, -DDEBUG, and -DPRODUCTION, to build information myModelBuildInfo. Group the definitions -DPROTO and -DDEBUG with the string Debug and the definition -DPRODUCTION with the string Release.
myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, {'-DPROTO -DDEBUG'
'-DPRODUCTION'}, {'Debug' 'Release'});addCompileFlags, addLinkFlags
Programming a Post Code Generation Command
![]() | addCompileFlags | addIncludeFiles | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |