主要内容

编译配置

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

要控制和配置生成二进制代码的编译过程,需要使用许多参数和设置。这些设置用来控制一些属性,如输出的编译类型(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.createCreate target object
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 起)
findBuildArgFind a specific build argument in build information
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

代码配置设置

全部展开

编译类型Output to build from generated C/C++ code
语言Language to use in generated code
语言标准Language standard to use for the generated code
自定义输出文件Name of code generation output file
仅生成代码Generation of only source code
验证模式Code verification mode
编译文件夹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 和图刷新的响应Responsiveness checks
保留外部调用Extrinsic function call support
检查内存完整性Memory integrity checking
对整数溢出进行饱和处理Integer overflow support
仅支持纯整数Detection of floating-point code
支持非有限数Support for nonfinite values
循环展开阈值Threshold on the number of iterations that determines whether to automatically unroll a for-loop and a parfor-loop
保留入口函数的输入数据是否保护入口函数输入数据不被修改
尽可能启用 OpenMP 库Parallelization of parfor-loops
启用自动并行化Automatic parallelization of for loops
最大 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
启用可变大小Variable-size array support
启用动态内存分配启用可变大小数组的动态内存分配
动态内存分配阈值Size threshold for dynamic memory allocation of variable-size arrays
对固定大小数组启用动态内存分配Dynamic memory allocation for fixed-size arrays
动态内存分配接口Dynamically allocated array at generated function interface
数组布局Row-major array layout
保留数组维度N 维索引
最大堆栈使用量Maximum stack usage per application
生成可重入代码Multi-instance, reentrant code
保留未使用的字段和属性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 function help text in function banner
需求汇总作为注释Include requirements links as comments
将 if-elseif-else 构型转换为 switch-case 语句Conversion of if-elseif-else patterns to switch-case statements
在函数声明中保留 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
缩进大小Number of characters per indentation level
列限制生成代码中换行符前的最大列数
数据类型替换Data type replacement in 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 global variable identifiers
全局类型Custom identifier format for global type identifiers
全局类型的字段名称Custom identifier format for field names in global type identifiers
局部函数Custom identifier format for local function identifiers
局部临时变量Custom identifier format for local temporary variable identifiers
常量宏Custom identifier format for constant macro identifiers
EMX 数组类型Custom identifier format for EMX array types
EMX 数组工具函数Custom identifier format for EMX array utility functions
生成的源文件和头文件名称格式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 compiler debugging mode
生成运行时错误检查Run-time error detection and reporting in generated code
显示详尽的编译器输出Code generation progress display
始终创建报告Code generation report
报告与 MATLAB 的差异Potential differences reporting
突出显示潜在的数据类型问题Highlighting of potential data type issues in the code generation report
突出显示潜在的行优先问题Potential row-major layout issues
突出显示隐式扩展导致的潜在问题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
将报告信息导出到变量Name of variable containing code generation report information
为 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 库Generate code that uses the FFTW library shipped with MATLAB
自定义 FFT 库回调Callback class for FFTW library calls
自定义 BLAS 库回调BLAS callback class
自定义 LAPACK 库回调LAPACK callback class
使用预编译库Whether to use precompiled libraries in generated code
源文件Code to appear near the top of generated .c or .cpp files
头文件Custom code that appears at top of generated C/C++ header files
初始化函数Custom code to include in the generated initialize function
终止函数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
代码生成后的命令Command to customize build processing
保留名称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
生产设备详细信息: doubleLength in bits of the C double data type
生产设备详细信息: 计算机字长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
生产设备详细信息:采用算术移位方式右移有符号整数Implementation of signed integer right shift as arithmetic right shift
生产设备详细信息:启用 long longLong long data type support
生产设备详细信息:最大原子整数大小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
测试设备详细信息: doubleLength in bits of the C double data type
测试设备详细信息: 计算机字长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
工具链Toolchain to use for building a C/C++ library or executable program
自定义工具链选项Custom settings for tools in selected toolchain
编译配置 Compiler optimization or debug settings for toolchain
测试硬件与生产硬件相同Equivalence of production and target hardware characteristics
C++ 命名空间Namespace name for generated C++ code
接口样式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++ 类Generate C++ classes for MATLAB classes
从 MATLAB 枚举生成 C++ 枚举类Whether to generate C++ enumeration classes for MATLAB enumerations
强制转换模式Data type casting level
常量折叠超时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
生成示例主函数Example C/C++ main file generation
保留变量名称Variable names to preserve in the generated code
回显不带终止分号的表达式Expression echoing
生成联编文件Makefile generation
自动引入外部调用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
启用代码可追溯性Traceability in code generation report
使用 Embedded Coder 功能Whether to use Embedded Coder features
启用隐式扩展Implicit expansion capabilities in generated code
启用自动并行化报告Reporting for automatic parallelization of for loops
启用运行时递归Run-time recursion support
缓存动态数组数据Dynamic array optimization
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.CodeConfigConfiguration parameters for C/C++ code generation from MATLAB code
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.hardwareCreate hardware board configuration object for C/C++ code generation from MATLAB code
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管理目标硬件和编译工具信息

主题

编译配置基础知识

特定编译选项

故障排除

精选示例