Eigen和GCC 5:不推荐使用class std :: binder2nd

Amx*_*mxx 12 gcc bind2nd eigen

我刚刚重新启动了一个暂停了几个月的项目.上次我编译它它工作得很好,没有任何错误或警告.然而,当我今天早些时候尝试编译它时,我得到了这个警告

attention : ‘template<class _Operation> class std::binder2nd’ is deprecated [-Wdeprecated-declarations]
Run Code Online (Sandbox Code Playgroud)

这个警告字面上出现了数百次,包括我在项目中使用的Eigen/Geometry

In file included from [...]/include/Eigen/src/Core/ArrayBase.h:109:0,
                 from [...]/include/Eigen/Core:350,
                 from [...]/include/Eigen/Geometry:4,
                 from [...]/include/[myproject]/types.hh:8,
                 from [...]/include/[myproject]/voronoi.hh:8
Run Code Online (Sandbox Code Playgroud)

从那以后我没有更新Eigen(使用3.2.4,这仍然是今天的最后一次更新).但是,自从我上次编译它以来,GCC已经更新到5.1.0(我使用的是archlinux)

题:

  • 是否存在gcc 5.1.0的问题,告诉我std :: binder2nd已被弃用
  • 应该更新Eigen吗?
  • 如何在不失去构建的冗长的情况下沉默这些特定的警告?

回答

我推测这std::bind2nd是非常弃用的,并且已经完成了提交以解决在Eigen中的问题.然而,这个提交尚未与主分支合并:/(并没有解决问题,因为一些std::bind2nd仍存在于Eigen的代码中)

底线是:不推荐使用Eigen的最后一个稳定版本

Jon*_*ely 10

  • 是否存在gcc 5.1.0的问题,告诉我std :: binder2nd已被弃用

不,C++标准说它在C++ 11中已被弃用,所以如果你在C++ 11模式下编译,那么它应该被弃用.

  • 应该更新Eigen吗?

是.如果它想要与C++ 17兼容,那么std::bind2nd在C++ 14之后根本就不存在.

  • 如何在不失去构建的冗长的情况下沉默这些特定的警告?

取消警告.-Wno-deprecated-declarations在命令行上编译或在包含Eigen头时在源代码中编译:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <eigen/whatever.h>
#pragma GCC diagnostic pop
Run Code Online (Sandbox Code Playgroud)

或者,正如另一个答案所说,告诉GCC将Eigen标头视为系统标头,如果它们在/usr/include,或包含在其中-isystem,或包含在另一个标头中,则会自动发生:

#pragma GCC system_header
#include <eigen/whatever.h>
Run Code Online (Sandbox Code Playgroud)