TITLE: for loop scope preprocessor hack (Newsgroups: comp.lang.c++.moderated, 25 Aug 97) [ The draft standard was recently changed such that the variable i in the following code snippet is undefined after the for loop for (int i = 0; i< myMax; i++) { ... } int j = i; // illegal, i undefined Not all compilers have caught up to this specification. VC++ 5.0 and likely other compilers allow the assignment to j. -adc ] CANTRELL: Wood Cantrell > A particular question: Is there a way (compiler flag or pragma) to > make VC++ 5.0 respect the scoping of a variable declared in a 'for' > statement? JONKER: "Todd V. Jonker" #define for if (0) {} else for (I can't take credit for this ingenious hack. I first saw it in James Clark's code for the SP SGML parsing system.)