robotology / osqp-eigen

Simple Eigen-C++ wrapper for OSQP library
https://robotology.github.io/osqp-eigen/
BSD 3-Clause "New" or "Revised" License
396 stars 118 forks source link

Warning of the MPC example compilation #36

Closed chibi314 closed 4 years ago

chibi314 commented 5 years ago

Hi. When I compile the MPC example, there appears lots of warnings. The following is one of them.

/home/anzai/Library/osqp-eigen/example/src/MPCExample.cpp: In function ‘int main()’:
/home/anzai/Library/osqp-eigen/example/src/MPCExample.cpp:260:48: warning: ‘bool OsqpEigen::Data::setHessianMatrix(const Eigen::SparseMatrix<Scalar>&) [with T = double]’ is deprecated: Use setHessianMatrix(const Eigen::SparseCompressedBase<Derived> &hessianMatrix) instead [-Wdeprecated-declarations]
     if(!solver.data()->setHessianMatrix(hessian)) return 1;

What is the best way to cope with this warning? And what is the best way to convert Eigen::Dense matrix to Eigen::SparseCompressedBase matrix?

xmba15 commented 4 years ago

If you just want to get rid of the warnings, maybe you can just apply a pragma flag to temporarily ignore them.

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  // your code
#pragma GCC diagnostic pop
xmba15 commented 4 years ago

Supposed that you are using gcc or clang for as your compiler.

GiulioRomualdi commented 4 years ago

Solved thanks to #48