Compilation Issue.

K

karthik.naig

Hi,

I am writing code for an Atmega645. I use the IAR compiler (v4.2).
I noticed that this piece of the code was not working. Meaning even if
the if condition evaluated to 0, it did not enter the loop. I am not
sure if I cleaned up all the project files before issuing a build (but
I think I did). But I know I issued a build several time and observed
this problem at all times.


{
if ( !GetMessageCount() )
{
..........do something....

return;
}

....do something else....
return.
}

However, when I changed it to this, it worked.

{
if ( GetMessageCount() == 0)
{
..........do something....

return;
}

....do something else....
return.
}

Further, when I changed it back again, it worked properly !!!

How can you explain that?

Btw, GetMessageCount is defined below.
unsigned char GetMessageCount()
{
return MessageCount;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top