This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/CC3200:TI 编译器预处理器中的错误-#define float 常量设置为零

Guru**** 2811895 points

Other Parts Discussed in Thread: CC3200SDK, CC3200

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/602527/compiler-cc3200-bug-in-ti-compiler-preprocessor---define-float-constant-is-set-to-zero

器件型号:CC3200

工具/软件:TI C/C++编译器

我对此感到困惑、TI ARM 编译器似乎有错误行为。

#define API_POLL_queue_interval 30.0f

const float _API_POLL_queue_interval=30.0f;

报告("添加#define float + const float:%f +%f =%f\n\r"、API_POLL_queue_interval、_API_POLL_queue_interval、API_POLL_queue_queue_interval+_API_POLL_queue_interval);

-->输出

添加#define float + const float:0.000000 + 30.000000 = 30.000000

我使用的是 TI 编译器 v5.2.8、这是我所使用的库所必需的

这在严格和宽松 FP 模式下都发生

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    事实证明、它不是预处理器。

    事实证明、浮点算术在函数参数中无法正常工作。 甚至与字面量不符。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Tim、

    可以发送代码片段吗?

    ~Roger
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    这是上面的代码片段。

    我看到的是、浮点算术没有正确评估、尽管在宽松模式下有如下语句:

    浮点 A = 2.0 + 2.0;

    有些工作。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Tim、

    上面的代码片段对我来说是可以的、因此我想其他一些选项是不同的。

    您能否尝试此测试以确保我们使用相同的测试用例?

    #include "hw_types.h"
    #include "hw_memmap.h"
    #include "hw_gpio.h"
    #include "hw_ints.h"
    
    #include "interrupt.h"#include "rom.h"
    #include "rom_map.h"
    #include "gpoll_float
    
    
    
    
    
    nstalt (#include "interrupt.h")#define api_float 3gpot_f_unt = nst.out (void)#define api_float npot_train pt
    
    pst.h)#include "n.out (#float npst.out (#include "nfpnpnp.out)、void api20_fp_float ine_pst.h
    
    
    
    
    报告("添加#define float + const float:%f +%f =%f\n\r"、a、b、A+b);
    }
    
    void FlotestatPrint (void)
    {
    报告("添加#define float + const float:%f +%f =%f\n\r"、API_POLL_queue_interval、_API_POLL_queue_interval+_API_POLL_queue_interval);
    }
    
    
    void main ()
    {
    MAP_IntVTableBaseSet ((无符号长整型)&g_pfnVectors[0]);
    MAP_IntMasterEnable();
    MAP_IntEnable (FAULT_SysTick);
    PRCMCC3200MCUInit();
    
    MAP_PRCMPeripheralClkEnable (PRCM_GPIOA1、PRCM_RUN_MODE_CLK);
    MAP_PinTypeGPIO (PIN_01、PIN_MODE_0、false);
    MAP_GPIODirModeSet (GPIOA1_base、0x4、GPIO_DIR_MODE_OUT);
    MAP_PinTypeGPIO (PIN_02、PIN_MODE_0、false);
    MAP_GPIODirModeSet (GPIOA1_base、0x8、GPIO_DIR_MODE_OUT);
    
    InitTerm();
    
    testFloatAddAndPrint (API_POLL_queue_interval+_API_POLL_queue_interval、API_POLL_queue_interval+_API_POLL_queue_interval);
    testFloatAddAndPrint (API_POLL_queue_interval、_API_POLL_queue_interval);
    testFloatPrint();
    } 

    谢谢、

    ~Roger

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Roger、您好、谢谢、这是一种很好的方法。

    我使用我的现有编译器和设置编译了 main.c。

    我必须删除 FreeRTOS 标志并从现有项目中添加 STARTUP_CCS.c 和 UART_IF.c。

    这是我得到的输出:

    添加#define float + const float:60.000000 + 60.000000 = 120.000000

    添加#define float + const float:30.000000 + 30.000000 = 60.000000

    添加#define float + const float:0.000000 + 30.000000 = 60.000000

    这与我看到的不同,但仍然很疯狂

     

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我从编译器5.2.8切换到16.9.0 LTS、并且获得了相同的输出:

    添加#define float + const float:60.000000 + 60.000000 = 120.000000

    添加#define float + const float:30.000000 + 30.000000 = 60.000000

    添加#define float + const float:0.000000 + 30.000000 = 60.000000

    您得到了什么输出?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    嗯,还可以

    如果您还没有添加几个编译器开关、您能否添加这些开关。

    1. -PDR (--iss问题_remarks)(添加额外的编译器备注)

    这将生成编译器备注、并可能为我们提供一些线索。

     2.-ppl (--preproc_with_line)-ppa (--preproc_with_compile)(生成.pp 预处理器文件并继续)

    这将在预处理器之后生成.pp 文件,并为您提供如下所示的内容:-

    const float _API_POLL_queue_interval=30.0f;
    
    void testFloatAddAndPrint (float a、float b)
    {
    报告("添加#define float + const float:%f +%f =%f\n\r"、a、b、A+b);
    }
    
    void FlotestatPrint (void)
    {
    报告("添加#define float + const float:%f +%f =%f\n\r"、30.0f、_API_POLL_queue_interval、30.0f+_API_POLL_queue_queue_interval);
    }
    
    
    void main ()
    {
    IntVTableBaseSet ((unsigned long)&g_pfnVectors [0]);
    IntMasterEnable();
    内部使能(15);
    PRCMCC3200MCUInit();
    
    PRCMPeripheralClkEnable (0x00000007、0x00000001);
    PinTypeGPIO (0x00000000、0x00000000、0);
    GPIODirModeSet (0x40005000、0x4、0x00000001);
    PinTypeGPIO (0x00000001、0x00000000、0);
    GPIODirModeSet (0x40005000、0x8、0x00000001);
    
    InitTerm();
    
    testFloatAddAndPrint (30.0f+_API_POLL_queue_interval、30.0f+_API_POLL_queue_interval);
    testFloatAddAndPrint (30.0f、_API_POLL_queue_interval);
    testFloatPrint();
    } 

    我得到了预期的输出:-

    添加#define float + const float:60.000000 + 60.000000 = 120.000000
    添加#define float + const float:30.000000 + 30.000000 = 60.000000
    添加#define float + const float:30.000000 + 30.000000 = 60.000000
    

    您能否发送完整的编译选项?

    ~Roger

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我从严格 FP 模式切换到宽松 FP 模式、得到了相同的答案。

    我还关闭了-fp_reassoc 选项、我得到了相同的答案:

    添加#define float + const float:60.000000 + 60.000000 = 120.000000

    添加#define float + const float:30.000000 + 30.000000 = 60.000000

    添加#define float + const float:0.000000 + 30.000000 = 60.000000

    但是、我将--float_support 从 fpalib 更改为 vfplib、并且输出发生变化:

    添加#define float + const float:60.000000 + 60.000000 = 120.000000
    添加#define float + const float:30.000000 + 30.000000 = 60.000000
    添加#define float + const float:30.000000 + 30.000000 = 60.000000


     

     

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Roger、

    -pdr -ppl 和-ppa 在 CCS 中不适用于我。 我是否必须在命令行上设置这些参数?

    以下是 CCS 报告的标志:

    -mv7M4 --code_state=16 --float_support=fpsalib -me -off --opt_for_speed=0 --fp_mode=relaxed --include_path="/Applications/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.0.LTS/include /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/oslib /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/simplelink /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/simplelink/source /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/inc /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/example/common --include_path="/Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/simplelink_extlib/provisioninglib /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/driverlib /Users/tim/ti/CC3200SDK_1.2.0/cc3200-sdk/simplelink/include --include_path=exccs_off-exccs_remark=-ccs_remark=-eces=-ccs_remote_remote_bes=-ccs-ecnates=-ecnates=-ecnatese-band-ecnates=-ecnate-be-ccs_remote_remote_remote_remote_remote_remote_remote_remotes=-ccs-ccs-ccs-eces=-ccs-ccs-ccs-ccs-ccs-ccs-econ-ecnecnecnecneces=-trads=-ctrads=-ccs-ccs-ccs_be-be-badse-be-be-be-be-be-b

    似乎--float_support 是问题所在、我不记得项目中何时设置了这个问题。

    您推荐的 cc3200 FP 支持选项有哪些?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    啊、我看到您正在使用 fpalib。

    我想您可能会遇到 SDSCM00044035。 (C:\ti\ccsv7\tools\compiler\ti-cgt-arm_16.9.3.LTS \Open_缺陷.html)

    我会使用--float_support=vfplib。

    ~Roger

    供参考-如果您将来需要,我提到的其他选项是较长选项的别名:-
    -PDR、--issed_remarks
    -ppa、--preproc_with_compile
    -ppl、--preproc_with_line

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢 Roger

    我不确定具体何时设置了该选项、但在修复错误之前、TI 是否会考虑在 CCS 中禁用此选项?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Tim、

    是的、我同意-我们绝对需要研究如何避免再次点击这个。

    ~Roger