Software development industry analysis by Larry O'Brien, the former editor of Software Development and Computer Language
Friday, July 21, 2006

The C99 language standard added support for variable length arrays (VLAs):

void foo(int len){
  float myArray[len];
  ...
}

In porting some C# code to C++, I had a method signature like that, so I tried to use a VLA. Sadly, VC++ 2005 produces "error C2057: expected constant expression," "error C2466: cannot allocate an array of constant size 0," and "error C2133: 'myArray' : unknown size". I've confirmed that this is a compliance thing: the code works with

gcc -std=iso9899:1999
. Pity.

Friday, July 21, 2006 11:17:54 AM (Hawaiian Standard Time, UTC-10:00) |  Disqus link  | Knowing | C++#
Search
About Larry...
Flickr photostream
Subscribe: RSS 2.0 Atom 1.0
Popular Articles
Programming Sabre with Java, C#, and XML
Genetic Programming in C#
15 Exercises To Know A Programming Language
Top 10 Things I've Learned About Computers From the Movies and Any Episode of "24"
Recently Published Articles
HI
KonaKoder
Categories
Archive
Admin Login
Sign In
Toolroll