主要内容

编译配置

编译设置的配置,例如输出文件的名称、位置、类型、语言

要控制和配置生成二进制代码的编译过程,需要使用许多参数和设置。这些设置用来控制一些属性,如输出的编译类型(MEX、lib、dll 或 exe),以及输出的语言是 C 还是 C++ 等等。其他编译设置允许您根据特定要求自定义编译输出,例如可读性、性能和外部代码集成。您可以从 App 或在命令行中修改代码生成配置对象中的编译选项。使用 coder.config 创建配置对象。使用 open 在编辑 App 中打开对象。要从函数代码内指定其他编译文件和标志,请使用 coder.updateBuildInfo

函数

全部展开

coder.config创建代码生成配置对象
coder.updateBuildInfo更新 RTW.BuildInfo 编译信息对象
target.addAdd target object to internal database
target.clearClear all target objects from internal database (自 R2023a 起)
target.create创建目标对象
target.exportExport target object data
target.getRetrieve target objects from internal database
target.removeRemove target object from internal database
target.updateUpdate target objects in internal database (自 R2023a 起)
target.upgradeUpgrade existing definitions of hardware devices
addCompileFlagsAdd compiler options to build information
addDefinesAdd preprocessor macro definitions to build information
addIncludeFilesAdd include files to build information
addIncludePathsAdd include paths to build information
addLinkFlagsAdd link options to build information
addLinkObjectsAdd link objects to build information
addNonBuildFilesAdd nonbuild-related files to build information
addPreincludeFilesAdd preinclude files to build information (自 R2024a 起)
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addUndefinesAdd undefine preprocessor directives to build information (自 R2024a 起)
removeIncludePathsRemove include paths from build information (自 R2023b 起)
removeSourceFilesRemove source files from build information object (自 R2021b 起)
removeUndefinesRemove undefine preprocessor macros from build information (自 R2024a 起)
findBuildArg在编译信息中查找特定编译参量
findIncludeFilesFind and add include (header) files to build information
getBuildArgsGet build arguments from build information
getCompileFlagsGet compiler options from build information
getDefinesGet preprocessor macro definitions from build information
getFullFileListGet list of files from build information
getIncludeFilesGet include files from build information
getIncludePathsGet include paths from build information
getLinkFlagsGet link options from build information
getNonBuildFilesGet nonbuild-related files from build information
getPreincludeFilesGet preinclude files from build information (自 R2024a 起)
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
getUndefinesFrom build information, get preprocessor macros to undefine (自 R2024a 起)
setTargetProvidesMainDisable inclusion of code generator provided (generated or static) main.c source file during build
updateFilePathsAndExtensionsUpdate files in build information with missing paths and file extensions
updateFileSeparatorUpdate file separator character for file lists in build information

代码配置设置

全部展开

编译类型要从生成的 C/C++ 代码编译的输出
语言要在生成代码中使用的语言
语言标准Language standard to use for the generated code
自定义输出文件Name of code generation output file
仅生成代码仅生成源代码
验证模式代码验证模式
编译文件夹Folder type for files generated during build process
编译文件夹路径Folder path for files generated during build process
工作文件夹Current working folder type for build process
工作文件夹路径Current working folder path for build process
启用对 CTRL+C 和图刷新的响应响应性检查
保留外部调用Extrinsic function call support
检查内存完整性Memory integrity checking
对整数溢出进行饱和处理Integer overflow support
仅支持纯整数Detection of floating-point code
支持非有限数支持非有限值
循环展开阈值Threshold on the number of iterations that determines whether to automatically unroll a for-loop and a parfor-loop
保留入口函数的输入数据是否保护入口函数输入数据不被修改
尽可能启用 OpenMP 库Parallelization of parfor-loops
启用自动并行化for 循环的自动并行化
最大 CPU 线程数运行并行 for 循环的最大 CPU 线程数
利用目标硬件指令集扩展SIMD instruction set for target hardware
FMAWhether to use SIMD instructions for fused multiply add operations
用户编写的 MATLAB 函数的内联策略Control inlining between user-written functions
MathWorks 编写的 MATLAB 函数的内联策略Control inlining between MathWorks functions
MathWorks 函数和用户函数之间调用的内联策略Control inlining between user-written functions and MathWorks functions
优化归约Generate SIMD code for reduction operations | Parallelize for-loops performing reduction operations
硬件 SIMD 加速Level of SIMD intrinsics
全局数据同步模式Global data synchronization mode
启用可变大小可变大小数组支持
启用动态内存分配启用可变大小数组的动态内存分配
动态内存分配阈值可变大小数组的动态内存分配的大小阈值
对固定大小数组启用动态内存分配固定大小数组的动态内存分配
动态内存分配接口Dynamically allocated array at generated function interface
数组布局行优先数组布局
保留数组维度N 维索引
最大堆栈使用量每个应用程序的最大堆栈使用量
生成可重入代码多实例、可重入代码
保留未使用的字段和属性Preserve unused class properties or structure fields in the generated C/C++ code
生成文件的分区方法File partitioning mode
大型常量生成Whether to write large deep learning constants to binary data files
大型常量阈值Threshold above which the code generator writes DNN constants to binary data files
包括注释Comments in generated code
注释样式Comment style in the generated code
MATLAB 源代码作为注释Inclusion of MATLAB source code as comments in generated code
MATLAB 源代码注释行号Include line numbers of MATLAB source code as comments in the generated code
MATLAB 函数帮助文本 函数前注中的 MATLAB 函数帮助文本
需求汇总作为注释将需求链接作为注释包含在内
将 if-elseif-else 构型转换为 switch-case 语句if-elseif-else 构型到 switch-case 语句的转换
在函数声明中保留 extern 关键字Preservation of the extern keyword in function declarations
使用有符号左移位进行定点运算和 2 次幂的乘法Replacement of multiplications by powers of two with signed left bitwise shifts
允许有符号整数右移Signed right bitwise shifts in generated code
圆括号Parenthesization level in the generated code
最大标识符长度Maximum number of characters in generated identifiers
头文件防卫式声明样式Style of preprocessor directive in generated code
缩进样式Style for placement of braces in the generated code
缩进大小每个缩进级别的字符数
列限制生成代码中换行符前的最大列数
数据类型替换生成代码中的数据类型替换
启用自定义数据类型替换Custom names for data types in generated code
从外部头文件导入自定义类型Whether to import type definition from external header files
头文件External header files that contain custom type definitions
全局变量全局变量标识符的自定义标识符格式
全局类型全局类型标识符的自定义标识符格式
全局类型的字段名称Custom identifier format for field names in global type identifiers
局部函数局部函数标识符的自定义标识符格式
局部临时变量Custom identifier format for local temporary variable identifiers
常量宏常量宏标识符的自定义标识符格式
EMX 数组类型EMX 数组类型的自定义标识符格式
EMX 数组工具函数EMX 数组工具函数的自定义标识符格式
生成的源文件和头文件名称格式File name customization macro
代码生成模板文件Code generation template for file and function banners
选择要使用的代码格式工具Formatting tool for generated code
控制 clang 格式配置文件的使用Control generation of clang-format file
启用 C/C++ 编译器调试模式C 编译器调试模式
生成运行时错误检查Run-time error detection and reporting in generated code
显示详尽的编译器输出Code generation progress display
始终创建报告代码生成报告
报告与 MATLAB 的差异Potential differences reporting
突出显示潜在的数据类型问题Highlighting of potential data type issues in the code generation report
突出显示潜在的行优先问题潜在的行优先布局问题
突出显示隐式扩展导致的潜在问题Highlight potential implicit expansion issues
突出显示使用 coder.loop 函数的潜在问题Highlight potential loop control issues
生成静态代码度量报告Static code metrics report
生成代码替换报告Code replacement report
生成报告后自动启动报告Automatic open of code generation report
将报告信息导出到变量包含代码生成报告信息的变量的名称
为 SIL 或 PIL 启用源代码级别调试Debugging of generated code during a SIL or PIL execution
检查常量输入Constant input checking mode for a SIL or PIL execution
同步全局数据Global data synchronization mode for a SIL or PIL execution
启用入口函数执行探查Execution time profiling during a SIL or PIL execution
启用函数执行探查Execution time profiling of functions called within entry-point functions during a SIL or PIL execution
指定探查保存选项Collection and storage of execution-time measurements
启用入口函数堆栈探查Stack usage profiling during a SIL or PIL execution
启用 C/C++ 代码覆盖率Analysis of C/C++ code coverage
启用执行探查Instrumentation for profiling
代码替换库Code replacement library for generated code
使用内置 FFTW 库生成使用 MATLAB 附带的 FFTW 库的代码
自定义 FFT 库回调Callback class for FFTW library calls
自定义 BLAS 库回调BLAS callback class
自定义 LAPACK 库回调LAPACK callback class
使用预编译库Whether to use precompiled libraries in generated code
源文件出现在生成的 .c.cpp 文件顶部附近的代码
头文件出现在生成的 C/C++ 头文件顶部的自定义代码
初始化函数要包含在生成的初始化函数中的自定义代码
终止函数Code that appears in the generated terminate function
其他包括目录Include folders to add to include path for compiling generated code
其他源文件Source files to compile and link with the generated code
其他库Static library files to link with the generated code
代码生成后的命令自定义编译处理的命令
保留名称Names that code generator must not use for functions or variables
硬件板Name of hardware board
生产设备详细信息:设备供应商Manufacturer of production hardware
生产设备详细信息:设备类型Type of production hardware
生产设备详细信息: charLength in bits of the C char data type
生产设备详细信息: shortLength in bits of the C short data type
生产设备详细信息: intLength in bits of the C int data type
生产设备详细信息: longLength in bits of the C long data type
生产设备详细信息: long longLength in bits of the C long long data type
生产设备详细信息: floatLength in bits of the C floating-point data type
生产设备详细信息: doubleC double 数据类型的长度(以位为单位)
生产设备详细信息: 计算机字长Microprocessor native word size
生产设备详细信息: 指针Length in bits of pointer data
生产设备详细信息: size_tLength in bits of size_t data
生产设备详细信息: ptrdiff_tLength in bits of ptrdiff_t data
生产设备详细信息:字节顺序Significance of the first byte of a data word
生产设备详细信息:采用算术移位方式右移有符号整数将有符号整数右移实现为算术右移
生产设备详细信息:启用 long longlong long 数据类型支持
生产设备详细信息:最大原子整数大小Largest atomic integer size for production hardware
生产设备详细信息:最大原子浮点数大小Largest atomic floating-point size for production hardware
生产设备详细信息:有符号整数除法舍入方式Rounding for division of two signed integers
目标设备详细信息:设备供应商Manufacturer of test hardware
目标设备详细信息:设备类型Type of test hardware
测试设备详细信息: charLength in bits of the C char data type
测试设备详细信息: shortLength in bits of the C short data type
测试设备详细信息: intLength in bits of the C int data type
测试设备详细信息: longLength in bits of the C long data type
测试设备详细信息: long longLength in bits of the C long long data type
测试设备详细信息: floatLength in bits of the C floating-point data type
测试设备详细信息: doubleC double 数据类型的长度(以位为单位)
测试设备详细信息: 计算机字长Microprocessor native word size
测试设备详细信息: 指针Length in bits of pointer data
测试设备详细信息: size_tLength in bits of size_t data
测试设备详细信息: ptrdiff_tLength in bits of ptrdiff_t data
测试设备详细信息:字节顺序Significance of the first byte of a data word
测试设备详细信息:采用算术移位方式右移有符号整数将有符号整数右移实现为算术右移
测试设备详细信息:启用 long longlong long 数据类型支持
测试设备详细信息:最大原子整数大小Largest atomic integer size for test hardware
测试设备详细信息:最大原子浮点大小Largest atomic floating-point size for test hardware
测试设备详细信息:有符号整数除法舍入方式Rounding for division of two signed integers
工具链用于编译 C/C++ 库或可执行程序的工具链
自定义工具链选项Custom settings for tools in selected toolchain
编译配置 Compiler optimization or debug settings for toolchain
测试硬件与生产硬件相同Equivalence of production and target hardware characteristics
C++ 命名空间生成的 C++ 代码的命名空间名称
接口样式Interface style for generated C++ code
C++ 接口类名称Interface class name for generated C++ code
从 MATLAB 命名空间生成 C++ 命名空间Generate C++ namespaces for MATLAB namespaces
MathWorks 代码的命名空间Place C++ code generated for MathWorks code in a separate namespace
从 MATLAB 类生成 C++ 类MATLAB 类生成 C++ 类
从 MATLAB 枚举生成 C++ 枚举类Whether to generate C++ enumeration classes for MATLAB enumerations
强制转换模式数据类型强制转换级别
常量折叠超时Maximum number of instructions to be executed by the constant folder
编译时递归限制Maximum number of function specializations for compile-time recursion
自动运行初始化函数Automatically run the initialize function
需要初始化函数Initialize function generation
需要终止函数Terminate function generation
为已知的 MISRA 违规生成申述注释Add annotations to suppress known MISRA/AUTOSAR violations
生成示例主函数示例 C/C++ 主文件生成
保留变量名称Variable names to preserve in the generated code
回显不带终止分号的表达式Expression echoing
生成联编文件联编文件生成
自动引入外部调用Automatic extrinsic function calls
简化数组索引Strength reduction optimization
使用 memcpy 进行向量赋值 Whether to enable memcpy optimization
Memcpy 阈值(字节)Minimum size for memcpy or memset optimization
使用 memset 将浮点数和双精度值初始化为 0.0Assignment of float and double zero with memset
常量输入Constant input checking mode
对 MEX 的编译类型使用 JIT 编译Just-in-time (JIT) compilation mode
生成非有限值的支持文件(使用时)Generate support files for nonfinite data only if nonfinite data is used
按引用向入口函数传递结构体Pass structures by reference
始终为 switch 生成默认 caseDefault case for all switch statements
启用代码可追溯性代码生成报告中的可追溯性
使用 Embedded Coder 功能是否使用 Embedded Coder 功能
启用隐式扩展生成代码中的隐式扩展功能
启用自动并行化报告Reporting for automatic parallelization of for loops
启用运行时递归运行时递归支持
缓存动态数组数据动态数组优化
SIL/PIL 详细程度Display communication I/O information during SIL or PIL execution
SIL/PIL 探查度量PMU metric

对象

coder.MexCodeConfigConfiguration parameters for MEX function generation from MATLAB code
coder.CodeConfigMATLAB 代码生成 C/C++ 代码的配置参数
coder.EmbeddedCodeConfigConfiguration parameters for C/C++ code generation from MATLAB code with Embedded Coder
coder.HardwareImplementationHardware-specific configuration parameters for C/C++ code generation from MATLAB code
coder.hardware为从 MATLAB 代码的 C/C++ 代码生成创建硬件板配置对象
coder.ReplacementTypesConfiguration parameter to specify custom names for MATLAB built-in data types in C/C++ code generation
RTW.BuildInfo提供用于编译和链接生成的代码的信息

coder.ExternalDependencyInterface to external code
target.AliasCreate alternative identifier for target object
target.CMakeSpecify CMake installation for building generated code (自 R2022b 起)
target.CMakeBuilder Configure how CMake builds generated code (自 R2022b 起)
target.CMakeBuildTypeDescribe CMake build type or build configuration (自 R2022b 起)
target.CMakeCacheEntryConfigure a CMake cache entry (自 R2022b 起)
target.EnvironmentConfigurationConfigure system environment for toolchain (自 R2022b 起)
target.HardwareComponentSupportDescribe support for a hardware component (自 R2022b 起)
target.LanguageImplementation提供 C 和 C++ 编译器实现详细信息
target.Object用于目标类型的基类
target.ProcessorProvide target processor information
target.ToolchainCapture high-level information about toolchain (自 R2022b 起)

命名空间

target管理目标硬件和编译工具信息

主题

编译配置基础知识

特定编译选项

故障排除

精选示例