Controlling Variable Scope in for Statements

If you enable the Legacy for-scoping setting , the compiler generates an error when it encounters a variable scope issue that the ISO C++ standard disallows, but is allowed in the C++ language specified in The Annotated C++ Reference Manual.

With this option off, the compiler allows variables defined in a for statement to have scope outside the for statement.

Listing 1. Example of a Local Variable Outside a for Statement

for(int i=1; i<1000; i++) { /* ... */ }
return i; // OK in ARM, Error in Carbide.c++

This setting corresponds to the pragma ARM_conform. To check this setting, use __option (ARM_conform). By default, this setting is off.

See Checking Option Settings for information on how to use this directive.