hI; perhaps try to remove comments after
a #define or #if define checks, in general avoid comments after a # statement.
#if 1 //depending on 'if that calculation is done', the
result of bufs[0] will be 0x01 or 0x02...
total = (((uint16_t)bufr[0]) << 8) + ((uint16_t) (bufr[1] & 0xFF)); #endif
ACAV
From:
<address@hidden> To:
<address@hidden>,
Date:
01.12.2012 19:15 Subject:
[avr-gcc-list]
maybe a bug in gcc-avr? Sent by:
address@hidden
Hello together,
I've been thinking about something for the last days. Atm I guess the bug of my problem is in the avr-gcc.
Here my code:
uint16_t total=0, temp=0; uint8_t bufs[64]; uint8_t bufr[64]; ... if (usb_rawhid_recv(bufr, 50) == 64) { #if 1 //depending on 'if that calculation is done', the result of bufs[0]
will be 0x01 or 0x02...
total = (((uint16_t)bufr[0]) << 8) + ((uint16_t) (bufr[1] & 0xFF)); #endif temp = (((uint16_t)bufr[0]) << 8); //temp is 0x0200 bufs[0] = temp >> 8; bufs[1] = (((uint16_t)bufr[0]) << 8) >> 8;
Well, if bufr[0] is 0x02, then bufs[1] is also 0x02. That works fine. But bufs[0] is calculated wrong IN CASE that i also calculate the variable
"total" inside the "#if 1". (bufs[0] is then 0x01 instead of 0x02)
On the left side the working case (where total isn't calculated due to
the "#if 0") On the right side is my problem shown. I calculate the variable "total"
but gcc seems to ignore my typecasts.
What do you think? I hope the mailing list is the right place, where I should post my problem :)