I have come up against this error while porting some drivers from another processor
C1853: unary minus operator applied to unsigned type
The line in question is:
if(offset < 0)
bytes_to_new_posn -= (unsigned long)0 - offset;
bytes_to_new_posn is an unsigned long
offset is a long
How do I get round this?
Steve
You get this kind of warning for things like
unsigned char x, y;
x = -y;
I tried your code with my compiler (from CW 6.2), and did not had this warning from the compiler. Seems like this has been improved. I tried an older compiler from 2000 and had the same warning.
You may try the option
-Ont=-
which disables the '-' operation optimization.
In your case it is the simplest way if you change the
(unsigned long)0 - offset
to simply
0 - offset
(BTW: '(unsigned long)0' is the same as 0uL).
If you want to cast the minus operation result to unsigned long, then this should be
(unsigned long) (0-offset)
BK