Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/27/03 01:45
Read: times


 
#37365 - What's wrong with this C code?
Hi,

void foo(unsigned char count) {
while(count--) {
/* do something here */
}
}

I compiled this on the Keil C251 V3.2 C compiler and it compiled the wrong code. I looked at the assembler output and at the beginning of the loop, it cleared count to 0 so that the loop never gets executed. Is what I did at the while-statement violated some ANSI no-nos or something?

This,
while(count) {
count--;
/* do something here */
}
however, compiled the correct code.

Andy


List of 5 messages in thread
TopicAuthorDate
What's wrong with this C code?            01/01/70 00:00      
RE: What's wrong with this C code?            01/01/70 00:00      
RE: What's wrong with this C code?            01/01/70 00:00      
RE: What\'s wrong with this C code?            01/01/70 00:00      
RE: What\'s wrong with this C code?            01/01/70 00:00      

Back to Subject List