Timur Tabi wrote:
> Scott Wood wrote:
> 
>> It frees the variable up for later such blocks to use.  As does 
>> declaring iterators inside a for loop, but I guess that's forbidden as 
>> well. :-)
> 
> I'm not sure whether we want to allow the same variable to be defined
> more than once, even with the same type, inside a function.

What's wrong with this:?

for (i = 0; i < n; i++) {
        int j;
        ...
}

for (i = 0; i < m; i++) {
        int j;
        ...
}

>> Chances are it will allocate all stack space for all variables up front, 
>> regardless of where they're declared.
> 
> Yes, but it many cases it won't allocate any stack space at all because
> it will just keep the variable in a register.  My point was that if a
> variable is defined later in a function, then it's more likely to have
> limited scope, so the compiler will be more likely to use a register
> instead of stack to store it.

I don't think it will make a difference.  The compiler knows what the 
lifetime of the variable is, regardless of where you declare it.

-Scott
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to