Compiler Warning (level 4) C4289
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 4) C4289

nonstandard extension used : 'var' : loop control variable declared in the for-loop is used outside the for-loop scope

When compiling with /Ze, a variable declared in a for loop was used after the for-loop scope. A Microsoft extension to the C++ language allows this variable to remain in scope.

See /Zc:forScope for information about how to specify standard behavior in for loops with /Ze.

This warning is off by default. See Compiler Warnings That Are Off by Default for more information.

The following sample generates C4289:

// C4289.cpp
// compile with: /W4
#pragma warning(default:4289)
int main()
{
   for (int i = 0 ; ; ) // C4289
      break;
   i++;
}
Show:
© 2016 Microsoft