Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
"error C2057: expected constant expression", "error C2466: cannot allocate an array of constant size
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="hn.ft.pris, post: 2597431"] "Erik Wikström 写é“: " Yes, I get it. But how to explain the following odd behavior of MS VS8: int main(int argc, char** argv){ #define L 1.234 #define T static_cast<int>(L) int arr[T]; arr[0] = 1; cout << arr[0] << endl; return 0; } Fine, without any warnings or errors. int main(int argc, char** argv){ double L = 1.234; int T = static_cast<int>(L); int arr[T]; arr[0] = 1; cout << arr[0] << endl; return 0; } error C2057: expected constant expression; error C2466: cannot allocate an array of constant size 0, on MS VS8 while gcc 3.4.2 approve it. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
"error C2057: expected constant expression", "error C2466: cannot allocate an array of constant size
Top