As mentioned, VLA (Variable-Length Arrays) are a C feature, and more to the point a C99 feature which Visual Studio does not support. On Linux, Clang and Gcc both support C99 (and C11 I believe) and allow this syntax in C++ as an extension.
In C++, you can easily transform the code by switching to std::vector<float> for all simple arrays. Only A will require a bit more work:
- you can either use a
std::vector< std::vector<float> >, but then you lose contiguity and locality
- or you can use a flattened version
std::vector<float> A(2*len*2*len); but then you will lose access by A[i][j] which will have to be transformed into A[i*2*len + j] instead
In any case, you will need to update this code to make it work on Visual Studio.
EDIT: per your comment:
The function is called twice in the code, once as cubic_spline(cx, cf, 9); and once as cubic_spline(cx, cf, 18);. In the first example, cx and cy are int[9] and in the second example they're int[18].
In this case you can actually make the function a template:
template <size_t len>
void CLASS cubic_spline(int const (&x)[len], int const (&y)[len]) {
float A[2*len][2*len], b[2*len], c[2*len], d[2*len];
}
Note that I removed the last parameter, because it is no longer necessary. The type of x and y is int const (&)[len] which is a reference to an array of int const of length len.