We want to add -Werror=conversion
to our code base, but the header of the Eigen library will trigger a lot of these error. I am wondering what is the best approach here so that the compilation flag only applies to our code but not for third party header.
One solution we are thinking is to create a wrapper library for Eigen that only contains stuff we need. We will compile the wrapper without the flag. But this is a somewhat big undertaking. I am wondering if there are other solutions.
CodePudding user response:
You can create a header Eigen.h with this:
#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <Eigen/Core>
// ...
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
CodePudding user response:
With gcc you can include Eigen headers via -isystem
. They will be treated like system headers and no warnings will be reported. This silences all warnings, though with well tested 3rd party libraries this is usually ok.