主要内容

配置代码生成

配置代码生成设置,例如输出文件名、位置、类型、语言

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

函数

coder.config创建代码生成配置对象

代码配置设置

全部展开

编译类型要从生成的 C/C++ 代码编译的输出
语言要在生成代码中使用的语言
语言标准Language standard to use for the generated code
自定义输出文件Name of code generation output file
仅生成代码仅生成源代码
验证模式代码验证模式
编译文件夹Folder type 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
检查内存完整性内存完整性检查
对整数溢出进行饱和处理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
保留入口函数的输入数据是否保护入口函数输入数据不被修改
限定 C restrict 函数参量Annotate function declarations with the restrict keyword
尽可能启用 OpenMP 库parfor 循环的并行化
启用自动并行化for 循环的自动并行化
最大 CPU 线程数运行并行 for 循环的最大 CPU 线程数
利用目标硬件指令集扩展SIMD instruction set for target hardware
FMA是否对融合乘加运算使用 SIMD 指令
用户编写的 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 for placement of braces in the generated code
缩进大小每个缩进级别的字符数
列限制生成代码中换行符前的最大列数
数据类型替换生成代码中的数据类型替换
启用自定义数据类型替换生成代码中数据类型的自定义名称
从外部头文件导入自定义类型Whether to import type definition from external header files
头文件External header files that contain custom type definitions
全局变量全局变量标识符的自定义标识符格式
全局类型全局类型标识符的自定义标识符格式
全局类型的字段名称全局类型标识符中字段名称的自定义标识符格式
局部函数局部函数标识符的自定义标识符格式
局部临时变量局部临时变量标识符的自定义标识符格式
常量宏常量宏标识符的自定义标识符格式
EMX 数组类型EMX 数组类型的自定义标识符格式
EMX 数组工具函数EMX 数组工具函数的自定义标识符格式
生成的源文件和头文件名称格式File name customization macro
代码生成模板文件用于文件和函数前注的代码生成模板
选择要使用的代码格式工具Formatting tool for generated code
控制 clang 格式配置文件的使用Control generation of clang-format file
启用 C/C++ 编译器调试模式C 编译器调试模式
生成运行时错误检查生成代码中的运行时错误检测和报告
显示详尽的编译器输出代码生成进度显示
始终创建报告代码生成报告
报告与 MATLAB 的差异潜在差异报告
突出显示潜在的数据类型问题Highlighting of potential data type issues in the code generation report
突出显示潜在的行优先问题潜在的行优先布局问题
突出显示隐式扩展导致的潜在问题突出显示潜在的隐式扩展问题
突出显示使用 coder.loop 函数的潜在问题Highlight potential loop control issues
生成静态代码度量报告Static code metrics report
生成代码替换报告Code replacement 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
启用执行探查用于探查的插桩
代码替换库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++ 头文件顶部的自定义代码
初始化函数要包含在生成的初始化函数中的自定义代码
终止函数出现在生成的终止函数中的代码
其他包括目录Include folders to add to include path for compiling generated code
其他源文件Source files to compile and link with the generated code
其他库要与生成代码链接的静态库文件
代码生成后命令自定义编译处理的命令
保留名称Names that code generator must not use for functions or variables
硬件板硬件板的名称
生产设备详细信息:设备供应商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
生产设备详细信息: floatC 浮点数据类型的长度(以位为单位)
生产设备详细信息: doubleC double 数据类型的长度(以位为单位)
生产设备详细信息: 计算机字长Microprocessor native word size
生产设备详细信息: 指针指针数据的长度(以位为单位)
生产设备详细信息: 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
生产设备详细信息:最大原子浮点数大小生产硬件的最大原子浮点大小
生产设备详细信息:有符号整数除法舍入方式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
测试设备详细信息: floatC 浮点数据类型的长度(以位为单位)
测试设备详细信息: 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++ 命名空间MATLAB 命名空间生成 C++ 命名空间
MathWorks 代码的命名空间将为 MathWorks 代码生成的 C++ 代码放置在单独的命名空间中
从 MATLAB 类生成 C++ 类MATLAB 类生成 C++ 类
从 MATLAB 枚举生成 C++ 枚举类Whether to generate C++ enumeration classes for MATLAB enumerations
强制转换模式数据类型强制转换级别
常量折叠超时常量折叠器要执行的最大指令数
编译时递归限制用于编译时递归的最大函数特化数
自动运行初始化函数自动运行初始化函数
需要初始化函数初始化函数生成
需要终止函数Terminate function generation
为已知的 MISRA 违规生成申述注释添加注解以隐藏已知的 MISRA/AUTOSAR 违规
生成示例主函数示例 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 阈值(字节)memcpymemset 优化的最小大小
使用 memset 将浮点数和双精度值初始化为 0.0Assignment of float and double zero with memset
常量输入Constant input checking mode
对 MEX 的编译类型使用 JIT 编译即时 (JIT) 编译模式
生成非有限值的支持文件(使用时)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 功能
启用隐式扩展生成代码中的隐式扩展功能
启用自动并行化报告for 循环的自动并行化的报告
启用运行时递归运行时递归支持
缓存动态数组数据动态数组优化
SIL/PIL 详细程度在 SIL 或 PIL 执行期间显示通信 I/O 信息
SIL/PIL 探查度量PMU metric

对象

coder.MexCodeConfigMATLAB 代码生成 MEX 函数的配置参数
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

主题

编译配置基础知识

特定编译选项