avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Tiny88 C++ code optimized out of existence?


From: Preston Wilson
Subject: Re: [avr-gcc-list] Tiny88 C++ code optimized out of existence?
Date: Wed, 14 Jan 2009 14:18:35 -0500
User-agent: Microsoft-Entourage/11.4.0.080122

"Bob Paddock" wrote:

>>>   for(;;)
>>>     {
>>>       uint8_t byte_u8 = LED2H; // Start LED
>> 
>> You're initializing the variable inside the loop.
> 
> I knew I was overlooking the obvious.  Thanks.
> 
> Still not sure why I was getting the warning about byte_u8
> not being used, when it was not in the loop, which
> is how it got in there in the first place, trying to figure
> out where the warning was coming from.
> 
> I deleted the .dep directory and OBJs then recompiled, and it went
> away.

The declaration would be fine if it were static
i.e.
for (;;) {
    static uint8_t byte_u8 = LED2H;  // Start LED
    ...
}

In this case the initial assignment is guaranteed to happen only once, but
obviously, static is not what you always want, but in this particular case
it would also fix the problem.

-Preston






reply via email to

[Prev in Thread] Current Thread [Next in Thread]