>>> I don't see the problem either. Local variables allocated in
>>> main are very likely to end up on the stack permanently. So
>>> moving a local variable into global space is fixing the
>>> problem without additional costs.
>>
>> If the variable is initialized, making it global may actually
>> save flash memory, since it will be initiazized by the startup code
>> loop that intiailzes all static data instead of by specific
>> code in main's preamble.
>
> ok, to be exact.
> the global initialized variable is put in .data section. this section is
> part of image, which resides in FLASH.
> gdb is sure about such section is exist, so the only, single variable
> satisfies it. no more global variables, if you prefer, may exist.
> is it clear enough?
I'm not sure whom you're addressing or what question you're
trying to answer. I was pointing out that an initialized
automatic variable in a function that doesn't return (e.g.
main) requires more flash than an initialized _static_ variable
does. So as long as an initialized variable is never going to
go out of scope, making it static will save flash and require
the require exactly the same amount of RAM.
--
Grant Edwards grante Yow! After this, I'm going
at to BURN some RUBBER!!
visi.com