主要内容

IAR Embedded Workbench 编译器 (-compiler iar-ew)

指定 IAR Embedded Workbench 编译器

描述

如果您使用 IAR Embedded Workbench 编译器编译您的代码,请为编译器 (-compiler) 选项指定 iar-ew。当您使用的语法不是标准语法,而是来自语言扩展时,通过指定您的编译器,可以避免此类语法导致编译错误。

然后,指定您的目标处理器类型。如果您为编译器选择了 iar-ew,则在 Polyspace® 桌面端产品的用户界面中,您只能看到 IAR Embedded Workbench 编译器允许的处理器。您选择的目标处理器决定了基础数据类型的大小、目标计算机的端序,以及特定的关键字定义。

如果您指定 iar-ew 编译器,则必须指定您的编译器头文件的路径。请参阅为 Polyspace 分析提供标准库头文件

设置

对于各个基础类型,目标使用以下默认大小(以位为单位)。您在 Polyspace 桌面端产品的用户界面中看不到这些大小。

目标charshortintlonglong longfloatdoublelong doubleptrchar 默认符号端序对齐size_t 的定义wchar_t 的定义
arm81632326432646432无符号Little64unsigned intshort
avr81616326432323216无符号Little8unsigned intunsigned short
msp43081616326432323216无符号Little16unsigned intunsigned short
rh85081632326432646432无符号Little32unsigned intshort
riscv81632326432646432无符号Little64unsigned intunsigned int
rl7881616326432323216无符号Little16unsigned intunsigned short

您的编译器设定还决定了许多编译器特定的宏的值。如果要了解 Polyspace 如何定义特定宏,请使用 -dump-preprocessing-info 选项。

提示

  • Polyspace 不支持使用 $Super$$$Sub$$ 来修补符号定义。例如,以下代码会正确编译,但 Polyspace 认为 main() 调用 extern func ($Super$$func) 而非调用此代码 ($Sub$$func) 中定义的函数 func

    /* void func() declared in another file */
    extern void $Super$$func(int i);
    
    int setup = 0;
    
    void setup_func(int i) {
      setup = i;
    }
    
    /* this function should be called instead of the original extern func() */
    void $Sub$$func(int i) {
      setup_foo(i); 
      /* does some extra setup work */   
      /* ... */
    }
    
    int main() {
      assert(setup = 0);
      func(1); // Should call $Sub$$func instead of $Super$$func
      assert(setup = 1);
      return 0;
    }
    为确保 Polyspace 在分析您的代码时调用正确的函数,请在预处理后在所有文件中将 $Sub$$ 的所有实例替换为一个空字符串。请参阅要应用于预处理文件的命令/脚本 (-post-preprocessing-command)

  • Polyspace 不支持某些特定于 IAR 编译器的构造。

    有关不支持的构造的列表,请参阅 polyspaceroot\polyspace\verifier\code_prover_desktop 中的 codeprover_limitations.pdf。其中,polyspaceroot 是 MATLAB® 的安装文件夹,例如 C:\Program Files\Polyspace\R2019a

  • 如果您使用 IDE 中的 Polyspace as You Code 扩展,请在分析选项文件中输入此选项。请参阅选项文件

命令行信息

参数:-compiler iar-ew -target
值:arm | avr | msp430 | rh850 | riscv | rl78
默认值:arm
示例 (Bug Finder):polyspace-bug-finder -compiler iar-ew -target rl78
示例 (Code Prover):polyspace-code-prover -compiler iar-ew -target rl78
示例 (Bug Finder Server):polyspace-bug-finder-server -compiler iar-ew -target rl78
示例 (Code Prover Server):polyspace-code-prover-server -compiler iar-ew -target rl78

版本历史记录

在 R2018a 中推出