2022-10-20 11:23 PM
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?
2022-10-21 12:55 AM
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.
2022-10-21 07:14 AM
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 )