Compiler Error C3286

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C3286.

specifier': an iteration variable cannot have any storage-class specifiers

See (NOTINBUILD)Storage-Class Specifiers for more information.

See for each, in for more information.

The following sample generates C3286.

// C3286.cpp  
// compile with: /clr  
int main() {  
   array<int> ^p = { 1, 2, 3 };  
   for each (static int i in p) {}   // C3286   
   for each (int j in p) {}   // OK  
}  

Show: