diff --git a/CMakeLists.txt b/CMakeLists.txt index 38e3d4976c..2a78ee9d62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_POSITION_INDEPENDENT_CODE ON) - +if(NOT MSVC) + # MSVC does not support variable length arrays (vla) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=vla") +endif() # casadi seems to compile without the newer versions of std::string add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) diff --git a/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp b/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp index c1c71a967d..ad51eda4e1 100644 --- a/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp +++ b/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp @@ -275,7 +275,7 @@ Solution CasadiSolverOpenMP::solve( // set inputs auto p_inputs = inputs.unchecked<2>(); - for (uint i = 0; i < functions->inputs.size(); i++) + for (int i = 0; i < functions->inputs.size(); i++) functions->inputs[i] = p_inputs(i, 0); // set initial conditions diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp b/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp index d29cb7c961..1a33b957f8 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp @@ -21,7 +21,7 @@ */ template void csc_csr(const realtype f[], const T1 c[], const T1 r[], realtype nf[], T2 nc[], T2 nr[], int N, int cols) { - int nn[cols+1]; + std::vector nn(cols+1); std::vector rr(N); for (int i=0; i newjac(SUNSparseMatrix_NNZ(JJ)); sunindextype *jac_ptrs = SUNSparseMatrix_IndexPointers(JJ); sunindextype *jac_vals = SUNSparseMatrix_IndexValues(JJ); @@ -229,7 +229,7 @@ int jacobian_casadi(realtype tt, realtype cj, N_Vector yy, N_Vector yp, p_python_functions->jac_times_cjmass.m_arg[2] = p_python_functions->inputs.data(); p_python_functions->jac_times_cjmass.m_arg[3] = &cj; - p_python_functions->jac_times_cjmass.m_res[0] = newjac; + p_python_functions->jac_times_cjmass.m_res[0] = newjac.data(); p_python_functions->jac_times_cjmass(); // convert (casadi's) CSC format to CSR @@ -237,7 +237,7 @@ int jacobian_casadi(realtype tt, realtype cj, N_Vector yy, N_Vector yp, std::remove_pointer_tjac_times_cjmass_rowvals.data())>, std::remove_pointer_t >( - newjac, + newjac.data(), p_python_functions->jac_times_cjmass_rowvals.data(), p_python_functions->jac_times_cjmass_colptrs.data(), jac_data, diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 27c1b0bcb1..8ab4e738fc 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -7,7 +7,7 @@ { "kind": "git", "repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git", - "baseline": "2aaffb6bba7bc0b50cb74ddad636832d673851a1", + "baseline": "af9f5e4bc730bf2361c47f809dcfb733e7951faa", "packages": ["sundials"] }, {