View unanswered posts | View active topics It is currently Sat Nov 01, 2014 1:33 am






Reply to topic  [ 3 posts ] 
Compiler warning about comparing signed and unsigned value 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Compiler warning about comparing signed and unsigned value
I have the following main task:
Code:
task main()
{
    long nextPeriod;

    RobotInit();
    nextPeriod = nPgmTime;
    while (true)
    {
        HiFreqTasks();
        if (nPgmTime >= nextPeriod)    <<< Compiler complains about this line
        {
            nextPeriod += LOOP_PERIOD;
            InputTasks();
            MainTasks();
            OutputTasks();
        }
        EndTimeSlice();
    }
}   //main

The compiler complains about "*Warning*:Comparison between 'signed' and 'unsigned' operands.". I checked the help topic on the intrinsic nPgmTime variable. It said it is a "const long". I declared nextPeriod to be long. So they are both signed. Does the help on nPgmTime lie? Changing the declaration of nextPeriod to be "unsigned long" get rid of the warning. It is not a big deal but reporting it nevertheless.


Fri Jul 26, 2013 5:03 pm
Profile
Rookie
User avatar

Joined: Wed Dec 01, 2010 5:15 pm
Posts: 31
Post Re: Compiler warning about comparing signed and unsigned val
This doesn't expalin the documentation, but in RobotCIntrinsics.c, the declaration of nPgmTime reads as follows:
Code:
intrinsic const unsigned long propertyIndex(nPgmTime,     propertySystem,        kSystemPgmTime);


Fri Jul 26, 2013 5:40 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3240
Location: Rotterdam, The Netherlands
Post Re: Compiler warning about comparing signed and unsigned val
Using a signed long for program time wouldn't make a lot of sense. It could cause problems with the space-time continuum, should the clock roll over into the negative.

= 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]


Sat Jul 27, 2013 12:32 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.