ROBOTC.net forums
http://robotc.net/forums/

*Warning*:Comparison between 'signed' and 'unsigned' operand
http://robotc.net/forums/viewtopic.php?f=11&t=11711
Page 1 of 1

Author:  getgray [ Sat Jul 11, 2015 8:01 pm ]
Post subject:  *Warning*:Comparison between 'signed' and 'unsigned' operand

Cortex, current firmware, Current RobotC 4.32

How do I fix this warning/error?

*Warning*:Comparison between 'signed' and 'unsigned' operands.

Here's a simple example that reproduces it:

Code:
   long temp;
   temp = nPgmTime;
   wait1Msec(10);
   if (temp > nPgmTime )
      temp = nPgmTime;



Errors on if or course. Help shows nPgmTime as long, and I have temp as long, don't understand the error.

Author:  mightor [ Sun Jul 12, 2015 3:04 am ]
Post subject:  Re: *Warning*:Comparison between 'signed' and 'unsigned' ope

nPgmTime is an unsigned long, temp is a signed long. You can fix this issue by simply declaring temp as an "unsigned long".
Code:
   unsigned long temp;
   temp = nPgmTime;
   wait1Msec(10);
   if (temp > nPgmTime )
      temp = nPgmTime;

This should do the trick. I have submitted a ticket in our system for the help to be fixed. Thank you for the heads up!

= Xander

Author:  getgray [ Sun Jul 12, 2015 11:48 am ]
Post subject:  Re: *Warning*:Comparison between 'signed' and 'unsigned' ope

mightor wrote:
nPgmTime is an unsigned long, temp is a signed long. You can fix this issue by simply declaring temp as an "unsigned long".
Code:
   unsigned long temp;
   temp = nPgmTime;
   wait1Msec(10);
   if (temp > nPgmTime )
      temp = nPgmTime;

This should do the trick. I have submitted a ticket in our system for the help to be fixed. Thank you for the heads up!

= Xander
Perfect, thank you! Maybe add "unsigned long" as possibilities to the help files data type section, so non C, new robotc guys like me can see it was an optional type to use.

Author:  mightor [ Sun Jul 12, 2015 2:22 pm ]
Post subject:  Re: *Warning*:Comparison between 'signed' and 'unsigned' ope

That is a good suggestion!

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/