主要内容

配置源代码和编译选项

配置 Polyspace 以紧密模拟您的编译,从而提高结果精度

如果您使用 makecmake 等编译命令来编译源代码,或者您能够使用编译系统生成 JSON 编译数据库,则可以通过编译命令或编译数据库来创建 Polyspace® 平台工程。Polyspace 平台工程中的源文件和编译选项由编译命令或编译数据库中的编译器调用决定。

否则,请在编译配置中显式设置选项。通过为编译工具链(静态分析) 选项指定编译器,可使分析器识别编译器特定的关键字。使用预处理器定义 (-D)要应用于预处理文件的命令/脚本 (-post-preprocessing-command) 等选项来解决任何其他错误。

函数

polyspace-configure(System Command) Create Polyspace Platform project, workspace, or options file from build command or compilation database

Polyspace 选项

全部展开

应用程序源文件 (-sources, -sources-list-file)Add source files to Polyspace Platform project
应用程序源文件夹Add source folders to Polyspace Platform project (自 R2024a 起)
包含路径 (-I)指定包含文件所在文件夹的路径
包括文件名模式Specify patterns for file names to be included in Polyspace Platform project (自 R2024a 起)
排除模式Specify folders or files to be excluded from static analysis or testing (自 R2024a 起)
工程变量Define environment variables for use as shorthands in Polyspace Platform project (自 R2024a 起)
源代码语言 (-lang)指定源文件的语言
C 标准版本 (-c-version)Specify C language standard followed in source code
C++ 标准版本 (-cpp-version)Specify C++ language standard followed in source code
用于静态分析的编译工具链 (-compiler, -compiler -target)Specify the compiler that you use to build your source code for static analysis
处理器 (-custom-target)Select the processor for the current build configuration
-targetSpecify size of data types and endianness by selecting a predefined target processor or creating a custom processor
如果文件无法编译,则停止分析 (-stop-if-compile-error)Specify that a compilation error must stop the analysis
隐式 C(C++) 编译器包含路径View implicit compiler include paths extracted from your build command (自 R2024b 起)
隐式 C(C++) 编译器定义View implicit compiler defines extracted from your build command (自 R2024b 起)
源代码编码 (-sources-encoding)指定源文件的编码
枚举类型定义 (-enum-type-definition)指定如何用基类型表示 enum
-ignore-pragma-pack忽略 #pragma pack 指令
-sfr-types为使用 Keil 或 IAR 编译器开发的代码指定 sfr 类型的大小
-no-uliteralsDisable Polyspace definitions for char16_t or char32_t
预处理器定义 (-D)替换预处理代码中的宏
已禁用的预处理器定义 (-U)取消定义预处理代码中的宏
要应用于预处理文件的命令/脚本 (-post-preprocessing-command)Specify command or script to run on source files after preprocessing phase of analysis
隐式 C(C++) 编译器定义View implicit compiler defines extracted from your build command (自 R2024b 起)
-regex-replace-rgx -regex-replace-fmtMake replacements in preprocessor directives
-dump-preprocessing-infoShow all macros implicitly defined during a particular analysis
包含路径 (-I)指定包含文件所在文件夹的路径
其他包含路径 (-I)Specify build-specific include paths in addition to project-wide include paths (自 R2024a 起)
强制包含文件 (-include)指定每个源文件必须通过 #include 包含的文件。 (自 R2023b 起)
隐式 C(C++) 编译器包含路径View implicit compiler include paths extracted from your build command (自 R2024b 起)
代码来自 DOS 或 Windows 文件系统 (-dos)注意文件路径是 MS-DOS 样式的
-include指定分析中的每个 C 文件要 #include 的文件
向下舍入负的整数相除结果 (-div-round-down)Specify that your compiler rounds down a negative quotient from dividing two integers (自 R2023b 起)
包对齐值 (-pack-alignment-value)为在 Visual C++ 中开发的代码指定默认结构体打包对齐值
指定编译器以算术移位方式右移有符号整数 (-logical-signed-right-shift)Specify that your compiler implements right shifts on signed integers as arithmetic shifts (自 R2023b 起)
名称查看 Polyspace 平台工程的名称 (自 R2024a 起)

主题

快速入门

使用编译命令配置选项

手动配置选项

对 C/C++ 语言标准和扩展的支持

疑难解答

Troubleshoot Compilation and Linking Errors

Learn why Polyspace compilation can fail even if your compiler build succeeds and how to work around the failures.