Error message "name lookup of 't' changed for ISO 'for' scoping"??

Here is the code that causes it:

1
2
3
for (int t = _T_START; t != _T_END; t++) { // error
  cout <<t;
}


where _T_START and _T_END are #defined. removing these and using numbers seems to fix the problem:

1
2
3
for (int t = 0; t != 10; t++) { //works fine
  cout <<t;
}


also declaring t outside the loop doesn't help:

1
2
3
4
int t;
for (t = _T_START; t != _T_END; t++) { //fail
  cout <<t;
}


I'd really appreciate if someone could tell me what on earth is going on here, thanks!
Where did you find these macros and why do you use them?
What do you mean by macro? I defined the _T_START and _T_END values myself. Interestingly, the following does work:

1
2
3
4
5
	
int t = _T_START;
for (; t != _T_END; t++) { // works!
  cout <<t;
}


So the problem doesn't seem to be the #defined values, but rather something about scoping that the compiler doesn't like, I just don't see what it could be...
Last edited on
ah crud my bad; I had semicolons after my #define statements for those values:

1
2
#define _T_START 1; //bad!
#define _T_END 20; //bad! 
Last edited on
This is one of the reasons why you should prefer const for constants.
Last edited on
Topic archived. No new replies allowed.