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;
}
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;
}