Main Content

addCompileFlags

Add compiler options to build information

Description

example

addCompileFlags(buildinfo,options,groups)specifies the compiler options to add to the build information.

The function requires thebuildinfoandoptionsarguments. You can use an optionalgroupsargument to group your options.

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

Examples

collapse all

Add the compiler option-O3to the build informationmyBuildInfoand place the option in the groupOPTS

myBuildInfo = RTW.BuildInfo; addCompileFlags(myBuildInfo,'-O3','OPTS');

Add the compiler options-Ziand-Wallto the build informationmyBuildInfoand place the options in the groupOPT_OPTS

myBuildInfo = RTW.BuildInfo; addCompileFlags(myBuildInfo,'-Zi -Wall','OPT_OPTS');

For a non-makefile build environment, add the compiler options-Zi,-Wall, and-O3to the build informationmyBuildInfo。Place the options-Ziand-Wallin the groupDebugand the option-O3in the groupMemOpt

myBuildInfo = RTW.BuildInfo; addCompileFlags(myBuildInfo,{'-Zi -Wall''-O3'},。..{'Debug''MemOpt'});

Input Arguments

collapse all

RTW.BuildInfoobject that contains information for compiling and linking generated code.

You can specify theoptionsargument as a character vector, as an array of character vectors, or as a string You can specify theoptionsargument as multiple compiler flags within a single character vector, for example'-Zi -Wall'。如果你指定optionsargument as multiple character vectors, for example,'-Zi -Wall'and'-O3',optionsargument is added to the build information as an array of character vectors.

Example:{'-Zi -Wall' '-O3'}

You can specify thegroupsargument as a character vector, as an array of character vectors, or as a string. If you specify multiplegroups, for example,'Debug' 'MemOpt',function relates thegroupsto theoptionsin order of appearance. For example, theoptionsargument{'-Zi -Wall' '-O3'}is an array of character vectors with two elements. The first element is in the'Debug'group and the second element is in the'MemOpt'group.

Note

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

For the build process to consider compiler flags in other groups, the template makefile must contain the token|>COMPILE_FLAGS_OTHER<|

Example:{'Debug' 'MemOpt'}

Version History

Introduced in R2006a