This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

if (0) condition, but entered.

Hi,

I am using GNU compiler in uVision 3.51. A portion of code is simliar to below:

X = 100; Y = 100; If(x!=y){ Xxxx; }else{ Yyyy; }

By using break point, i found that both Xxxx and Yyyy are entered. It happened in both subroutine, and main. Both X and Y are declared as unsigned integer as global variables. The entire code is less than 16K (about 70% of 16K). Do you have any idea on this? The IC used is LPC2129. Thanks for your advice.

Regards,

Parents
  • X = 100; Y = 100; If(x!=y){ Xxxx; }else{ Yyyy; }

    I assume you wanted to type

    x = 100;
    y = 100;
    if(x!=y)
       { Xxxx; }
    else
       { Yyyy; }
    

    The best practice to post code is to cut and paste it. Re-typing it always carries the danger of introducing typos, thereby obscuring the actual problem and leading the readers on a wild goose chase.

    But now, back to the original question.

    What optimization level are you using ? Higher optimization levels are usually not very conducive for debugging. Set the optimization level to the lowest possible and try again.

Reply
  • X = 100; Y = 100; If(x!=y){ Xxxx; }else{ Yyyy; }

    I assume you wanted to type

    x = 100;
    y = 100;
    if(x!=y)
       { Xxxx; }
    else
       { Yyyy; }
    

    The best practice to post code is to cut and paste it. Re-typing it always carries the danger of introducing typos, thereby obscuring the actual problem and leading the readers on a wild goose chase.

    But now, back to the original question.

    What optimization level are you using ? Higher optimization levels are usually not very conducive for debugging. Set the optimization level to the lowest possible and try again.

Children
No data