-Weffc++ and Eigen library
Alec Jacobson
October 14, 2012
I recently tried to make use of the -Weffc++
gcc compiler flag in my project. Unfortunately Eigen is not developed with these warnings in mind. So when I tried to use it I got a gazillion warnings from including Eigen headers. My solution was to move all Eigen includes to a single header (EigenConvenience.h
), which looks something like this:
#ifdef __GNUC__
// This is how it should be done
# if __GNUC__ >= 4
# if __GNUC_MINOR__ >= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Weffc++"
# endif
# endif
// This is a hack
# pragma GCC system_header
#endif
// Include all eigen headers here, e.g.
#include <Eigen/Dense>
#ifdef __GNUC__
# if __GNUC__ >= 4
# if __GNUC_MINOR__ >= 6
# pragma GCC diagnostic pop
# endif
# endif
#endif