In windows MSVC, I was trying to compile the below code.
void foo(std::vector<double> &bar){
const long int length = bar.size();
double a[length]; //error C3863: array type 'double [length]' is not assignable
for(int i=0; i < length; i++){
a[i]=0.0;
}
//do some other things
}
the code works fine in xcode.
When I switch to MSVC, compile the code with command line:
cl /EHsc main.cpp /std:c++17
Then I have the "error C3863: array type 'double [length]' is not assignable".
Why is it different? How to get rid of the error?