| Syntax: | Default: |
| lang(ansiForStatementScopes[,
yes]) lang(ansiForStatementScopes, no) |
lang(ansiForStatementScopes[, yes]) |
This option controls whether scope rules defined in the C++ standard apply to names declared in for-init statements.
By default, standard C++ rules are used. For example the following code causes a name lookup error:
{
//...
for (int i=1; i<5; i++) {
cout << i * 2 << endl;
}
i = 10; // error
}
The reason for the error is that i, or any name declared within a for-init-statement, is visible only within the for statement. To correct the error, either declare i outside the loop or set ansiForStatementScopes to no.
Set ansiForStatementScopes to no to allow old language behavior. You may need to do this for code that was developed with other products, such as the compilers provided by earlier versions of VisualAge C++ and predecessor products, and Microsoft Visual C++.
![]()
Incremental C++ Build
Configuration Files
![]()
Language Options for C++
Build Options for Compliance With the C++
Standard
Build Options for Compatibility with Old
C++ Compilers
