/Zc:forScope - Force Conformance in for Loop Scope (Windows CE 5.0)

Send Feedback

This option causes standard C++ behavior to occur in for loops with Microsoft extensions with the /Ze - Enable Language Extensions option**.**

/Zc:forScope

Remarks

Standard behavior allows the initializer of a for loop to go out of scope after the for loop. Under /Ze, the initializer remains in scope until the local scope ends.

The following code will compile under /Ze but not under /Za - Disable Language Extensions:

int main() {
// int i;
   {
   for (int i =0; i < 1; i++)
      ;
   i = 20;   // i has already gone out of scope under /Za
   }
}

If you use /Zc:forScope, you will get a warning if a variable is in scope because of a declaration that was made in a previous scope. To demonstrate this, remove the // characters in the above code to declare int i.

You can modify the run-time behavior of /Zc:forScope with the conform pragma.

If you use /Zc:forScope in a project with an existing .pch file, /Zc:forScope is ignored (with a warning) and compilation continues with the existing .pch files. If you want a new .pch file generated, use /Yc.

See Also

Compiler Options

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.