View unanswered posts | View active topics It is currently Sun Nov 17, 2019 9:26 am






Reply to topic  [ 4 posts ] 
*Warning*:Comparison between 'signed' and 'unsigned' operand 
Author Message
Rookie

Joined: Mon Oct 21, 2013 12:22 pm
Posts: 20
Post *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.


Sat Jul 11, 2015 8:01 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jul 12, 2015 3:04 am
Profile WWW
Rookie

Joined: Mon Oct 21, 2013 12:22 pm
Posts: 20
Post 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.


Sun Jul 12, 2015 11:48 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: *Warning*:Comparison between 'signed' and 'unsigned' ope
That is a good suggestion!

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jul 12, 2015 2:22 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.