coder.EmbeddedCodeConfig
Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder
Description
A coder.EmbeddedCodeConfig
object contains the
configuration parameters that codegen
uses for generating a static
library, a dynamically linked library, or an executable program with Embedded Coder®. Pass the object to the codegen
function by using the
-config
option.
Creation
Create a coder.EmbeddedCodeConfig
object by using the coder.config
function.
Once you create a coder.EmbeddedCodeConfig
object, you can modify
its properties programmatically at the command line or interactively by using the
Configuration Parameter Dialog Box. See Specify Code Configuration Parameters Interactively.
Properties
Compiler optimization or debug settings for toolchain, specified as
'Faster Runs'
, 'Faster Builds'
,
'Debug'
, or 'Specify'
. For more
information, see Build
configuration.
Dynamic array optimization, specified as true
or
false
. For more information, see Cache
dynamic array data.
Data type casting level for variables in the generated C/C++ code,
specified as 'Nominal'
, 'Standards'
,
or 'Explicit'
. For more information, see Casting
mode.
Control generation of clang-format
file to use for
formatting the generated code, specified as 'Generate'
or
'Existing'
. For more information, see Control
use of clang format configuration.
Analysis of C/C++ code coverage during a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution, specified as false
or true
. For more information, see Enable
C/C++ code coverage.
Execution-time profiling during a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution for entry points, specified as
false
or true
. For more
information, see Enable
execution profiling.
Formatting tool for the generated code, specified as
'Auto'
, 'Clang-format'
, or
'MathWorks'
. For more information, see Select
code format tool to use.
Performance Monitoring Unit (PMU) metric profiling of functions, specified as one of the values listed in this table.
Value | Description |
---|---|
"time" | Extracts no metric from the PMU of the target hardware. |
"totinstr" | Extracts total instruction count. |
"floatinsts" | Extracts FPU instruction count. |
"floatopts" | Extracts FPU operation count. |
"intinstr" | Extracts ALU instruction count. |
"loadinstr" | Extracts load instruction count. |
"storeinstr" | Extracts store instruction count. |
"totcyc" | Extracts total cycle count. |
"l1dcm" | Extracts L1 data cache misses. |
"l1icm" | Extracts L1 instruction cache misses. |
"l2dcm" | Extracts L2 data cache misses. |
"l2icm" | Extracts L2 instruction cache misses. |
"tlbdm" | Extracts TLB data misses. |
"tlbim" | Extracts TLB instruction misses. |
"memstall" | Extracts memory stall cycles. |
"totstall" | Extracts total stall cycles. |
For more information, see SIL/PIL profiling metrics.
Execution-time profiling of functions called within entry-point functions
during a software-in-the-loop (SIL) or processor-in-the-loop (PIL)
execution, specified as false
or true
.
For more information, see Enable
function execution profiling.
Collection and storage of execution-time measurements, specified as
"AllData"
, "SummaryOnly"
, or
"MetricsOnly"
. For more information, see Specify
profiling save options.
Code replacement library for generated code, specified as a character vector. For more information, see Code replacement library.
Stack usage profiling during a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution for entry-point functions, specified
as false
or true
. For more
information, see Enable
entry point stack profiling.
Code generation template for file and function banners in the generated
code, specified as a 0-by-0 array of
coder.MATLABCodeTemplate
classes or a
coder.MATLABCodeTemplate
object. For more
information, see Code
generation template file.
Maximum number of columns before a line break in the generated code, specified as a positive integer in the range [45, 65536]. For more information, see Column limit.
Comment style in the generated code, specified as
'Auto'
, 'Single-line'
, or
'Multi-line'
. For more information, see Comment
style.
Maximum number of function specializations for compile-time recursion, specified as a positive integer. For more information, see Compile-time recursion limit.
Maximum number of instructions that the constant folder executes, specified as a positive integer. For more information, see Constant folding timeout.
Conversion of if-elseif-else
patterns to
switch-case
statements in the generated code,
specified as false
or true
. For more
information, see Convert
if-elseif-else patterns to switch-case statements.
Whether to generate C++ code that contains enumeration classes, specified
as true
or false
. For more
information, see Generate
C++ enum class from MATLAB enumeration.
Interface class name for generated C++ code when
CppInterfaceStyle
is set to
'Methods'
, specified as a character vector. For more
information, see C++
interface class name.
Interface style for the generated C++ code for the MATLAB entry-point functions that you generate code from, specified
as 'Functions'
or 'Methods'
. For more
information, see Interface
style.
Namespace for the generated C++ code, specified as a character vector. For more information, see C++ namespace.
Place C++ code generated for MathWorks code in a separate namespace, specified as a character vector. For more information, see Namespace for MathWorks code.
Generate C++ classes for MATLAB classes, specified as true
or
false
. For more information, see Generate
C++ classes from MATLAB classes.
Generate C++ namespaces for MATLAB namespaces, specified as true
or
false
. For more information, see Generate
C++ namespaces from MATLAB namespaces.
BLASS callback class in code generated for certain low-level vector and matrix operations in MATLAB code, specified as a character vector. For more information, see Custom BLAS library callback.
Callback class for FFTW library calls in code generated for FFT functions in MATLAB code, specified as a character vector. For more information, see Custom FFT library callback.
File name customization macro, specified as a character vector. For more information, see Generated source and header file name format.
Custom code that appears at top of generated C/C++ header files generated
from your MATLAB code, except rtwtypes.h
and
rtwhalf.h
, specified as a character vector. For more
information, see Header
file.
Include folders to add to include path for compiling generated code, specified as a string array, cell array of character vectors, or character vector. For more information, see Additional include directories.
Custom code to include in the generated initialize function, specified as a character vector. For more information, see Initialize function.
LAPACK callback class in code generated for certain linear algebra functions in MATLAB code, specified as a character vector. For more information, see Custom LAPACK library callback.
Static library files to link with the generated code, specified as a string array, cell array of character vectors, or character vector. For more information, see Additional libraries.
Source files to compile and link with the generated code, specified as a string array, cell array of character vector, or character vector. For more information, see Additional source files.
Code to appear near the top of generated .c
or
.cpp
files, except rtwhalf.c
or
rtwhalf.cpp
, outside of
any function, specified as a character
vector. For more information, see Source
file.
Custom identifier format for EMX Array types (Embeddable mxArray types) in the generated code, specified as a character vector. For more information, see EMX array types.
Custom identifier format for EMX Array (Embeddable mxArrays) utility functions in the generated code, specified as a character vector. For more information, see EMX array utility functions.
Custom identifier format for local function identifiers in the generated code, specified as a character vector. For more information, see Local functions.
Custom identifier format for field names in global type identifiers in the generated code, specified as a character vector. For more information, see Field name of global types.
Custom identifier format for global variable identifiers in the generated code, specified as a character vector. For more information, see Global variables.
Custom identifier format for constant macro identifiers in the generated code, specified as a character vector. For more information, see Constant macros.
Custom identifier format for local temporary variable identifiers in the generated code, specified as a character vector. For more information, see Local temporary variables.
Custom identifier format for global type identifiers in the generated code, specified as a character vector. For more information, see Global types.
Code that appears in the generated terminate function, specified as a character vector. For more information, see Terminate function.
Custom settings for tools in selected toolchain, specified as a cell array. For more information, see Custom Toolchain Options.
Data type replacement in generated code, specified as 'CBuiltIn'
or
'CoderTypeDefs'
. For more information, see
Data type
replacement.
Configuration object for code generation for deep learning networks, specified as specified as one of the objects in this table.
Object | Requires | Description |
---|---|---|
coder.MklDNNConfig |
| A cfg = coder.config('mex'); cfg.TargetLang = 'C++'; cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn'); See Code Generation for Deep Learning Networks with MKL-DNN. |
coder.ARMNEONConfig |
| A cfg = coder.config('lib'); cfg.TargetLang = 'C++'; cfg.DeepLearningConfig = coder.DeepLearningConfig('arm-compute'); See Code Generation for Deep Learning Networks with ARM Compute Library. |
coder.CuDNNConfig (GPU Coder) |
| A cfg = coder.gpuConfig('lib'); cfg.TargetLang = 'C++'; cfg.DeepLearningConfig = coder.DeepLearningConfig('cudnn'); See Code Generation for Deep Learning Networks by Using cuDNN (GPU Coder). |
coder.TensorRTConfig (GPU Coder) |
| A cfg = coder.gpuConfig('lib'); cfg.TargetLang = 'C++'; cfg.DeepLearningConfig = coder.DeepLearningConfig('tensorrt'); See Code Generation for Deep Learning Networks by Using TensorRT (GPU Coder). |
Dependency: If DeepLearningConfig
is set,
codegen
sets TargetLang
to
C++
.
Object description, specified as a character vector.
Dynamic memory allocation mode, specified as one of the values in this table.
Value | Description |
---|---|
'Threshold' | This value is the default value. The code generator allocates
memory dynamically on the heap for variable-size
arrays whose size (in bytes) is greater than or
equal to
|
'AllVariableSizeArrays' | The code generator dynamically allocates memory for all variable-size arrays on the heap. |
'Off' | The code generator statically allocates memory for variable-size arrays on the stack. |
Unbounded variable-size arrays require dynamic memory allocation.
Dependencies:
EnableVariableSizing
enables this parameter.Setting this
DynamicMemoryAllocation
to'Threshold'
enables theDynamicMemoryAllocationThreshold
parameter.
See Generate Code for Variable-Size Arrays.
Note
The DynamicMemoryAllocation
configuration
object property will be removed in a future release. To dynamically
allocate memory for variable-sized arrays, use the
EnableDynamicMemoryAllocation
property. Use
the DynamicMemoryAllocationThreshold
property to
set the dynamic memory allocation threshold.
Dynamic memory allocation for fixed-size arrays, specified as
false
or true
. For more
information, see Enable
dynamic memory allocation for fixed-sized arrays.
Dynamically allocated array at generated function interface, specified as
'Auto'
, 'C'
, or
'C++'
. For more information, see Dynamic
memory allocation interface.
Size threshold for dynamic memory allocation of variable-size arrays, specified as a positive integer. For more information, see Dynamic memory allocation threshold.
Automatic extrinsic function calls, specified as true
or false
. For more information, see Automatically introduce extrinsic calls.
Automatic parallelization of for
-loops, specified as
false
or true
. For more
information, see Enable
automatic parallelization.
Reporting for automatic parallelization of for
loops,
specified as true
or false
. For more
information, see Enable
automatic parallelization reporting.
Custom names for data types in generated code, specified as
false
or true
. For more
information, see Enable
custom data type replacement.
Enable dynamic memory allocation for variable-size arrays, specified as
true
or false
. For more
information, see Enable
dynamic memory allocation.
Implicit expansion capabilities in the generated code, specified as
true
or false
. For more
information, see Enable
implicit expansion.
memcpy
optimization, specified as true
or false
. For more information, see Use
memcpy for vector assignment.
Parallelization of parfor
-loops, specified as
true
or false
. For more
information, see Enable
OpenMP library if possible.
Run-time recursion support, specified as true
or
false
. For more information, see Enable
run-time recursion.
Replacement of multiplications by powers of two with signed left bitwise
shifts in the generated C/C++ code, specified as true
or
false
. For more information, see Use
signed shift left for fixed-point operations and multiplication by
powers of 2.
Signed right bitwise shifts in generated code, specified as
true
or false
. For more
information, see Allow
right shifts on signed integers.
Strength reduction optimization, specified as false
or
true
. For more information, see Simplify
array indexing.
Traceability in code generation report, specified as
true
or false
. For more
information, see Enable
code traceability.
Variable-size array support, specified as true
or
false
. For more information, see Enable
variable-sizing.
File partitioning mode, specified as 'MapMFileToCFile'
'SingleFile'
. For more information, see Generated
file partitioning method.
Static code metrics report, specified as false
or
true
. For more information, see Generate
static code metrics report.
Generation of only source code, specified as true
or
false
. For more information, see Generate
code only.
Code replacement report, specified as false
or
true
. For more information, see Generate
code replacements report.
Comments in generated code, specified as true
or
false
. For more information, see Include
comments.
Default case for all switch statements,
specified as false
or true
. For more
information, see Always
generate a default case for switch.
Example C/C++ main file generation, specified as
'GenerateCodeOnly'
,
'DoNotGenerate'
, or
'GenerateCodeAndCompile'
. For more information, see
Generate
example main.
Makefile generation during the build process, specified
true
or false
. For more
information, see Generate
makefile.
Generation of support files for nonfinite data only if nonfinite data is
used, specified true
or false
. For
more information, see Generate
nonfinite support files if used.
Code generation report, specified false
or
true
. For more information, see Always
create a report.
Configuration object for generating CUDA GPU code using GPU Coder. A GpuCodeConfig
object contains parameters
specific to CUDA GPU code generation. To create a
GpuCodeConfig
object, use coder.gpuConfig
(GPU Coder). For example:
cfg = coder.gpuConfig('lib'); cfg.GpuConfig ans = GpuCodeConfig with properties: Enabled: 1 MallocMode: 'discrete' KernelNamePrefix: '' EnableCUBLAS: 1 EnableCUSOLVER: 1 EnableCUFFT: 1 Benchmarking: 0 SafeBuild: 0 ComputeCapability: 'Auto' CustomComputeCapability: '' CompilerFlags: '' StackLimitPerThread: 1024 MallocThreshold: 200 MaximumBlocksPerKernel: 0 EnableMemoryManager: 1 SelectCudaDevice: -1
For more information, see Generate Code Using the Command Line Interface (GPU Coder).
If GpuConfig
is set, the code generator uses fixed
values for certain properties that are required for GPU code generation.
Some properties also have different default values. For more information,
see Configure GPU Code Generation (GPU Coder).
Object that specifies a hardware board. To create the coder.Hardware
object, use coder.hardware
. For
example:
cfg = coder.config('lib'); hw = coder.hardware('Raspberry Pi'); cfg.Hardware = hw;
Before you use coder.hardware
, you must install the
support package for the hardware board.
Dependencies:
Setting
Hardware
customizes the hardware implementation object and other configuration parameters for a particular hardware board.If
DeepLearningConfig
is set to acoder.ARMNEONConfig
object andHardware
is empty, thencodegen
sets theGenCodeOnly
property totrue
.
Note:
Suppose that you create a
coder.CodeConfig
objectcfg
in a MATLAB session and use it in another MATLAB session. If the MATLAB host computer for the second session does not have the hardware board specified in thecfg.Hardware
property installed on it, this parameter reverts to its default value. The default value is[]
. Setting the Hardware Board option toMATLAB Host Computer
in the app is equivalent to usingcfg.Hardware
andcfg.HardwareImplementation.ProdHWDeviceType
with their default value.
To specify a hardware board for PIL execution, see PIL Execution with ARM Cortex-A at the Command Line (Embedded Coder).
Hardware implementation object that specifies hardware-specific
configuration parameters for C/C++ code generation. coder.config
creates a
coder.EmbeddedCodeConfig
object with the
HardwareImplementation
property set to a coder.HardwareImplementation
object with default parameter values for the MATLAB host computer.
Style of preprocessor directive in generated code, specified as
'UseIncludeGuard'
or
'UsePragmaOnce'
. For more information, see
Header
guard style.
Highlighting of potential data type issues in the code generation report,
specified as false
or true
. For more
information, see Highlight
potential data type issues.
Whether to highlight potential issues resulting from implicit expansion in
the code generation report, specified as true
or
false
. For more information, see Highlight
potential issues resulting from implicit expansion.
Whether to highlight potential issues resulting from the use of loop
control functions in the code generation report, specified as
true
or false
. For more
information, see Highlight
potential issues in use of coder.loop functions.
Potential row-major layout efficiency issues, specified
true
or false
. For more
information, see Highlight
potential row-major issues.
Initialize function generation, specified as true
or
false
. For more information, see Initialize function required.
Terminate function generation, specified as true
or
false
. For more information, see Terminate
function required.
Number of characters per indentation level in the generated code, specified as a positive integer in the range [2,8]. For more information, see Indent size.
Style for placement of braces in the generated code, specified as
'K&R'
or 'Allman'
. For more
information, see Indent
style.
Assignment of float and double zero with memset
,
specified true
or false
. For more
information, see Use
memset to initialize floats and doubles to 0.0.
Control inlining between MathWorks functions, specified as 'Speed'
,
'Always'
, 'Readability'
, or
'Never'
. For more information, see Inline
strategy for MathWorks written MATLAB functions.
Control inlining between user-written functions and MathWorks functions, specified as 'Speed'
,
'Always'
, 'Readability'
, or
'Never'
. For more information, see Inline
strategy for calls between MathWorks functions and user
functions.
Control inlining between user-written functions, specified as
'Speed'
, 'Always'
,
'Readability'
, or 'Never'
. For
more information, see Inline
strategy for user written MATLAB functions.
Instruction sets to generate single instruction, multiple data (SIMD) code for target hardware, specified as one of the values in this list:
'Auto'
'SSE'
'SSE2'
'SSE4.1'
'AVX'
'AVX2'
'FMA'
'AVX512F'
'Neon v7'
'None'
For more information, see Leverage target hardware instruction set extensions.
Options for the SIMD instruction sets of the
InstructionSetExtensions
setting, specified as a
InstructionSetExtensionsConfig
object. Use the
properties of the object to specify the options for the instruction sets.
This parameter is applicable for only the instruction set Neon
v7
.
Example: 'InstructionSetExtensionsConfig.FMA =
true'
Whether to use SIMD instructions from the
InstructionSetExtensions
setting for
fused multiply add operations, specified as
true
or false
. For
more information, see FMA.
Annotates the generated C/C++ code to suppress known MISRA™ and AUTOSAR violations, specified false
or
true
. For more information, see Generate
justification comments for known MISRA violations.
Whether to write large deep learning constants to binary data files for a
deep neural network (DNN), specified as
'WriteOnlyDNNConstantsToDataFiles'
or
'KeepInSourceFiles'
. For more information, see
Large
constant generation.
Threshold above which the code generator writes DNN constants to binary data files, specified as a positive integer. For more information, see Large constant threshold.
Automatic open of code generation report, specified
true
or false
. For more
information, see Automatically launch a report if one is generated.
Threshold on the number of iterations that determines whether to
automatically unroll a for
-loop or
parfor
-loop, specified as a positive integer. For
more information, see Loop
unrolling threshold.
MATLAB function help text in function banner in generated code,
specified as true
or false
. For more
information, see MATLAB
function help text.
Inclusion of MATLAB source code as comments in generated code, specified
true
or false
. For more
information, see MATLAB
source code as comments.
Include line numbers of MATLAB source code as comments in the generated code, specified as
true
or false
. For more
information, see MATLAB
source code comment line numbers.
Maximum number of characters in generated identifiers, specified as a positive integer in the range [31, 2048]. For more information, see Maximum identifier length.
Minimum size for memcpy or memset optimization in bytes, specified as a positive integer. For more information, see Memcpy threshold (bytes).
Multi-instance, reentrant code, specified as true
or
false
. For more information, see Generate
re-entrant code.
Object name, specified as a character vector.
Maximum number of CPU threads to run parallel for
-loops
in the generated C/C++ code, specified as a positive integer. For more
information, see Maximum
number of CPU threads.
Generate SIMD code for reduction operations and parallelize for-loops
performing reduction operations, specified as false
or
true
. For more information, see Optimize
reductions.
Output to build from generated C/C++ code, specified as
'LIB'
, 'DLL'
, or
'EXE'
. For more information, see Build
type.
Parenthesization level in the generated code, specified as
'Nominal'
, 'Minimum'
, or
'Maximum'
. For more information, see Parentheses.
Pass structures by reference to entry-point functions, specified
true
or false
. For more
information, see Pass
structures by reference to entry-point functions.
Command to customize build processing after MEX function generation with
codegen
, specified as a character vector. For more
information, see Post-code-generation command.
Generation of code that uses N-dimensional indexing, specified
false
or true
. For more
information, see Preserve
array dimensions.
Preservation of the extern
keyword in function
declarations in the generated code, specified as true
or
false
. For more information, see Preserve
extern keyword in function declarations.
Since R2024b
Whether to protect entry-point input data from modification when the
generated code is called from your custom C/C+ code, specified as
false
or true
. For more
information, see Preserve
input data for entry-point functions.
Preserve unused class properties or structure fields in the generated
C/C++ code, specified as false
or
true
. For more information, see Preserve
unused fields and properties.
Variable names to preserve in the generated code, specified as
'None'
, 'UserNames'
,
'All'
. For more information, see Preserve
variable names.
Detection of floating-point code, specified as false
or
true
. For more information, see Support
only purely-integer numbers.
Specify custom names for MATLAB data types in the generated code, specified as a coder.ReplacementTypes
object. You can specify custom names
for these built-in data types: double
,
single
, uint8
,
uint16
, uint32
,
uint64
, int8
,
int16
, int32
,
int64
, char
, and
logical
.
Dependency:
Setting
EnableCustomReplacementTypes
totrue
enables theReplacementTypes
parameter. See Customize Data Type Replacement (Embedded Coder).
Name of variable containing code generation report information about code generation, specified as a character vector. For more information, see Export report information to variable.
Potential difference reporting, specified true
or
false
. For more information, see Report
differences from MATLAB.
Include requirement links as comments in the generated code, specified as
true
or false
. For more
information, see Requirement summaries as comments.
Names that the code generator must not use for functions or variables, specified as a string array, cell array of character vectors, or character vector. For more information, see Reserved names.
Row-major array layout for the generated code, specified
false
or true
. For more
information, see Array
layout.
Automatically run the initialize function at the beginning of the
generated entry-point functions, specified true
or
false
. For more information, see Automatically run the initialize function.
Run-time error detection and reporting in generated code, specified
false
or true
. For more
information, see Generate
run-time error checks.
Integer overflow support, specified true
or
false
. For more information, see Saturate
on integer overflow.
Debugging of generated code during a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution, specified as false
or true
. For more information, see Enable
source-level debugging for SIL or PIL.
Constant input checking mode for a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution, specified as true
or false
. For more information, see Check
constant inputs.
Global data synchronization mode for a software-in-the-loop (SIL) or
processor-in-the-loop (PIL) execution, specified as true
or false
. For more information, see Synchronize global data.
Display of communication I/O information during software-in-the-loop (SIL)
or processor-in-the-loop (PIL) execution, specified as
'off'
or 'on'
. For more
information, see SIL/PIL
Verbosity.
Maximum stack usage per application in bytes, specified as a positive integer. For more information, see Stack usage max.
Support for nonfinite values, specified as true
or
false
. For more information, see Support
nonfinite numbers.
Language to use in generated code, specified as 'C'
or
'C++'
. For more information, see Language.
Language standard to use for the generated code, specified as one of these options:
'Auto'
'C89/C90 (ANSI)'
'C99 (ISO)'
'C++03 (ISO)'
'C++11 (ISO)'
'C++14 (ISO)'
'C++17 (ISO)'
'C++20 (ISO)'
For more information, see Language standard.
Toolchain to use for building a C/C++ library or executable program, specified as a character vector. For more information, see Toolchain.
Generate code that uses the FFTW library shipped with MATLAB for fast Fourier transform (FFT) functions in your MATLAB code, specified false
or
true
. For more information, see Use
built-in FFTW library.
Since R2024b
Whether to use precompiled libraries in generated code, specified as
'Prefer'
or 'Avoid'
. For more
information, see Use
precompiled libraries.
Code generation progress display, specified as one of the values in this table.
Value | Description |
---|---|
false | This value is the default value. The code generator does not display code generation progress. |
true | The code generator displays code generation progress, including code generation stages and compiler output. |
Note
The Verbose
configuration object property will
be removed in a future release. To view code generation progress,
use the Verbosity
property.
Code generation progress display at the MATLAB command line, specified as 'Info'
,
'Silent'
, or 'Verbose'
. For more
information, see Show
verbose compiler output.
Code verification mode, specified as 'None'
,
'SIL'
, or 'PIL'
. For more
information, see Verification mode.
Examples
Write a MATLAB function from which you can generate code. This example uses
the function myadd
that returns the sum of its
inputs.
function c = myadd(a,b) c = a + b; end
Create a configuration object for generation of standalone C/C++ code (a static library, a dynamically linked library, or an executable program). For example, create a configuration object for generation of a static library.
cfg = coder.config('lib');
If Embedded Coder is installed, coder.config
creates a
coder.EmbeddedCodeConfig
object.
Change the values of the properties for which you do not want to use the
default values. For example,change the comment style in the generated code
to single-line comments preceded by
//
.
cfg.CommentStyle = 'Single-line';
The
CommentStyle
property is available only in an
Embedded Coder configuration object.
Generate code by using codegen
. Pass the
configuration object to codegen
by using the
-config
option. Specify that the input arguments are
scalar
double.
codegen myadd -config cfg -args {1 1} -report
Alternative Functionality
To use default configuration parameters for build types 'LIB'
,
'DLL'
, or 'EXE'
, use the
codegen
option -config:lib
,
-config:dll
, or -config:exe
, respectively.
Then, you do not have to create and pass a configuration object to
codegen
.
Version History
Introduced in R2011aThe default setting for the
InlineBetweenUserAndMathWorksFunctions
code configuration
option is now 'Readability'
.
In addition to C++03 (ISO) and C++11 (ISO), the code generator can generate C++ code compatible with C++14 (ISO), C++17 (ISO), and C++20 (ISO).
New property CodeProfilingCodeMetrics
allows you to profile
generated code using metrics from the Performance
Monitoring Unit (PMU) of the hardware.
New property UsePrecompiledLibraries
allows you to specify the
extent to which the generated code uses platform-specific precompiled
libraries.
New property PreserveInputData
allows you to generate code that
protects entry-point input data from modification when the generated code is called
from your custom C/C+ code.
If you try to use quotes to specify a single filename or path that contains white
space (for example, '"folder1\folder2\sp ace\fun3.c"'
) for the
CustomInclude
, CustomLibrary
, and
CustomSource
code configuration parameters, the code
generator produces an error.
Specifying multiple file names, paths, or reserved names in code configuration
objects by using character vectors or string scalars that have delimiters produces
an error. Use string arrays and a cell array of character vector instead. For
example, to include multiple folder names, you can use either a string array in
CustomInclude
as cfg.CustomInclude =
["C:\Project","C:\Custom Files"];
or a cell array of character vectors
as cfg.CustomInclude = {'C:\Project','C:\Custom Files'};
to
include the path for compiling the generated code.
Using quotes to specify a single filename or path that contains white spaces (for
example, '"sp ace/fun3.c"'
) for the
CustomInclude
, CustomLibrary
, and
CustomSource
code configuration properties produces a warning
and will be removed in a future release.
In a future release, the DynamicMemoryAllocation
property will
be removed.
To dynamically allocate memory for variable-size arrays, use the
EnableDynamicMemoryAllocation
property. To configure the
dynamic memory allocation threshold, use
DynamicMemoryAllocationThreshold
property.
Specifying multiple file names, paths, or reserved names in code configuration
objects by using character vectors or string scalars that have delimiters produces a
warning and will be removed in a future release. Use string arrays and a cell array
of character vector instead. For example, to include multiple folder names, you can
use either a string array in CustomInclude
as
cfg.CustomInclude = ["C:\Project","C:\Custom Files"];
or a
cell array of character vectors as cfg.CustomInclude =
{'C:\Project','C:\Custom Files'};
to include the path for compiling
the generated code.
In a future release, specifying multiple file names, paths, or reserved names in
code configuration objects by using character vectors or string scalars that have
delimiters will be removed. Use string arrays and a cell array of character vector
instead. For example, to include multiple folder names, you can use either a string
array in CustomInclude
as cfg.CustomInclude =
["C:\Project","C:\Custom Files"];
or a cell array of character vectors
as cfg.CustomInclude = {'C:\Project','C:\Custom Files'};
to
include the path for compiling the generated code.
In a future release, the Verbose
property will be
removed.
To configure the code generation progress display, use the
Verbosity
property.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)