Main Content

addCompileFlags

Add compiler options to build information

Description

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

The function requires the buildinfo and options arguments. You can use an optional groups argument 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.

example

Examples

collapse all

Add the compiler option -O3 to the build information myBuildInfo and place the option in the group OPTS.

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

Add the compiler options -Zi and -Wall to the build information myBuildInfo and place the options in the group OPT_OPTS.

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

For a non-makefile build environment, add the compiler options -Zi, -Wall, and -O3 to the build information myBuildInfo. Place the options -Zi and -Wall in the group Debug and the option -O3 in the group MemOpt.

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

Input Arguments

collapse all

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

You can specify the options argument as a character vector, as an array of character vectors, or as a string You can specify the options argument as multiple compiler flags within a single character vector, for example '-Zi -Wall'. If you specify the options argument as multiple character vectors, for example, '-Zi -Wall' and '-O3', the options argument is added to the build information as an array of character vectors.

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

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' 'MemOpt', the function relates the groups to the options in order of appearance. For example, the options argument {'-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.

Example: {'Debug' 'MemOpt'}

Version History

Introduced in R2006a