NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

/Zc:forScope

/Zc:forScope

If you want standard behavior of for loops and Microsoft extensions (/Ze), use /Zc:forScope with /Ze, which is on by default.

Standard behavior is to let a for loop's initializer go out of scope after the for loop finishes. Under /Ze, the for loop's initializer remains in scope until the local scope ends.

The following code will compile under /Ze but not under /Za:

void 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

/Zc (Conformance)