mardi 4 septembre 2018

How to define a two dimensional array during run time in Visual Studio C++ 11?

I am trying to compile ORBSLAM2 on Windows with Visual Studio 2015 vc14 x64 compiler. The project was originally developed for GNU GCC. I now have the following issue:

// Compute distances between them
const size_t N = vDescriptors.size();

float aDistances[N][N];
for(size_t i=0;i<N;i++) {
    aDistances[i][i]=0;
    for(size_t j=i+1;j<N;j++) {
        int distij = ORBmatcher::DescriptorDistance(vDescriptors[i],vDescriptors[j]);
        aDistances[i][j]=distij;
        aDistances[j][i]=distij;
    }
}

I get the this error while compiling:

C2131 expression did not evaluate to a constant

... on this line of code:

const size_t N = vDescriptors.size();

Subsequently the two dimensional array definition fails too (float Distances[N][N];).

What's the best way to solve this in Visual-C++ ?

Aucun commentaire:

Enregistrer un commentaire