"new ISO 'for' scoping"


I have a problem with a simple ‘for’ loop.

I do one for loop inside another and I need to set back to zero the inner counter. However, if I do that I get the following strange error:

my code:

for (byte col=1; col<13 ; col++) { //
for (byte row=1; row<9 ; row++){
row = 1;


in function ‘void loop()’:
41:error: name lookup of ‘row’ changed for new ISO ‘for’ scoping
36:error: using obsolete binding at ‘row’

can anyone explain to me what is happening here, and if the counter needs to be setback to 1 ??

Thankx so much. I really do not understand this language.


"Scope" refers to where a variable is visible (i.e., accessible) in the language. By declaring the variable 'row' in the initialization part of the for-loop, its scope is the for-loop and therefore it has already "disappeared" by the time you try to set "row=1;".

But it's not necessary to set "row=1" manually (i.e., after the for-loop) because it is done automatically every time the inner for-loop begins. Just delete the "row=1;" line and all should be OK.

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons