[prog] Definining an array in Visual C++
Terri Oda
terri at zone12.com
Tue Mar 25 16:24:43 EST 2003
I know this isn't exactly the place to go for vc++ info, but I'm running out
of search terms to try in google, so I'm hoping someone here might know the
answer or have suggestions that'll help me find a solution.
I have a C++ program that I use under linux. It compiles nicely in gcc 3
without warnings, even.
We want it to run on a windows machine, so I got cygwin's gcc and gave it a
try, but unfortunately the (proprietary) optimization library I'm using gets
rather flustered and the include files go all wonky. Since visual c++ was
installed on the machine, I thought I'd give it a try (the library I'm using
does work happily with vc++). Unfortunately, I have some trouble with my
arrays.
Effectively, I'm doing this:
int nSize;
// ...
// nSize is set based on an array we read in
// ...
CostStruct L_data[nSize][nSize];
And the compiler dies when I hit that last line, saying that it wants a
constant. I tried making a little temporary constant variable
const int nSize_const = nSize;
but that didn't seem to help.
Now, I know I could just malloc the arrays I want, but it seems to me that I
*should* be able to do it this way, and I'm loathe to go into ifdefs if I
don't *have* to.
Can anyone think of something I can do to make visual c++ take array
definitions similar to those I used in gcc? Heck, even a cross-compiler
might work, although it's less than ideal.
Terri
More information about the Programming
mailing list