Menu

Warning: Comparison will fail if [variable] is any value other than 0 or 1: Resolved

mkstevo
2018-11-27
2019-03-26
  • mkstevo

    mkstevo - 2018-11-27

    Since updating to the latest release of Great Cow Basic v0.98.03, I am seeing this warning:
    Warning: Comparison will fail if [variable] is any value other than 0 or 1

    I assume this was always the case (that the comparison would fail) but I hadn't given it a whole lot of thought until I saw the warnings. When comparing the state of a pin with a variable I find it useful to store the 'idle' state of the pin in a variable so that I can then see if it has changed from the original value. I've been using byte variables for this (using bytes almost everywhere unless specifically needing a word or long) so the answer is to declare this variable of the type Bit. This does stop me from assigning a value of greater than one to indicate a 'starting' value and that the idle state should be tested.

    Posting this as a reminder to myself as much as anything. Hopefully in a few months time when something stops working with this error I'll remember the answer. Perhaps it will help someone else too.

     
  • Anobium

    Anobium - 2018-11-27

    This is a new feature within the compiler. We have a series of post when comparing values to bit. The feature resolves error that could occur. As you say using a BIT is the correct way forward.

    :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.