Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2010
Visual Studio
Visual C++
C/C++ Build Errors
 Compiler Error C2057
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
Visual Studio 2010 - Visual C++
Compiler Error C2057
expected constant expression

The context requires a constant expression, an expression whose value is known at compile time.

The following sample generates C2057:

// C2057.cpp
int i;
int b[i];   // C2057
int main() {
   const int i = 8;
   int b[i];
}

C has more restrictive rules for constant expressions. The following sample generates C2057:

// C2057b.c
#define ArraySize1 10
int main() { 
   const int ArraySize2 = 10; 
   int h[ArraySize2];   // C2057
   int h[ArraySize1];   // OK
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker