Page 1 of 1

Can't understand why I have this warning comparison of unsigned expression < 0 is always false

Posted: Thu Dec 15, 2022 12:01 pm
by lodogg
Hi, I can't understand why I have this kind of warning:
warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
The operation is:

Code: Select all

         if ( SUBSCRIPTION_EXPIRY_TIME - ((hwRtc - lastSub)*1000) < 0 )
where variable and definitions are:

Code: Select all

#define SUBSCRIPTION_EXPIRY_TIME    (5*60*1000)
time_t hwRtc
uint32_t lastSub
Seems that the result of the operation is considered as unsigned despite the presence of a signed variabile in it.
What am I missing?