Skip to main content
SHan.4
Visitor II
October 21, 2022
Question

SPC58nh-disp - I get a build error when I run the example

  • October 21, 2022
  • 2 replies
  • 1587 views

Hi, My discovery board is SPC58NH-DISP and I'm a beginner

I want to run the RTOS exampe.

so I tried running the example sequnce.

like picture....

umm..

I am getting a build error.

-----

./components/spc5_freertos_tcpip_component_rla/lib/src/FreeRTOS_IP.c:1782:32: warning: comparison of promoted ~unsigned with unsigned [-Wsign-compare]

-----

How can I solve this?

    This topic has been closed for replies.

    2 replies

    ODOUV.1
    ST Employee
    October 21, 2022

    Hello,

    this is not an error but a compilor warning

    if( pxICMPHeader->usChecksum >= FreeRTOS_htons( 0xFFFFu - usRequest ) )

    in this line, 0xFFFFu is a 32 bits unsigned value 65535

    usRequest is a 16 bit unsigned value

    usChecksum is a 16 bit unsigned value

    compiler suppose that u32 - u16 can be a negative value

    macro FreeRTOS_htons is casting this supposed negative value into an u16

    the comparison (<=) between a u16 and casted negative value can be an issue

    this is the reason of the warning

    BUT usRequest value is between 0 and 65535

    so 0xFFFFu - usRequest will remain between 65535 and 0

    so it cannot be negative, so there is no issue

    Best regards.

    ODOUV.1
    ST Employee
    October 21, 2022

    you could try this:

    /**

    * Fix warning: comparison of promoted ~unsigned with unsigned

    *

    * with uint16_t format:

    * 0xFFFFu - usRequest == ~usRequest

    *

    */

    uint16_t temp = ~usRequest;

    if( pxICMPHeader->usChecksum >= temp )